Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: JimmyTHi,
I'm interested to reduce a counter value (in the case below, field BalCredits) when certain conditions are met.
For example, there are 4 fields in total. Name, Charge, StartCredits, BalCredits.
Under field Name, there is only two types of values, Adam and Eve.
Under field Charge, there are 2 different charges, $0.20 (when field BalCredit = 0) and $0.00 (when field BalCredit > 0)
Under field StartCredits, $1.00, for each respective person i.e. Adam / Eve
Under BalCredits, value ranges from $1.00 to $0.00 for each Adam and Eve, a deduction of $0.20 for every record by Adam or Eve
For the above scenario, I used an agg node (on field Name) with the following script, but doesn't seem to work. The result of the following script outputs the value of BalCredits in the following order. $1.00, $0.80, $0.60, $0.40,$0.20, 5.55111512313e-017, -$0.20, $0.00
if firstInGroup then BalCredits = StartCredits
if BalCredits > 0 then BalCredits = BalCredits - 'Charge'
emit *,
BalCredits as "BalCredits"
All advice welcome!,
Jim
Attachments:
Discount Counter.zip