Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi community,
I have the following table:
FieldA | FieldB | FieldC
boss boss 4
boss worker 3
boss boss 3
boss worker 4
worker boss 1
worker worker 4
So i want a field where i do the avg of field C when Field A= Field B
I tryed this Sum({$<FieldA= p(FieldB)>}FieldC)/count({$<FieldA=p(FieldB)>}FieldC)
and this
I tryed this Sum({$<FieldA= FieldB>}FieldC)/count({$<FieldA=FieldB>}FieldC)
Neither worked.
Any ideas?
Thanks in advance
Best Regards
Bruno Paulo
May be create a flag in the script
LOAD FieldA,
FieldB,
FieldC,
If(FieldA = FieldB, 1, 0) as MatchFlag
FROM....
and then this
Sum({<MatchFlag = {1}>}FieldC)/Count({<MatchFlag = {1}>}FieldC)
Try this may be?
= Sum(IF(FieldA = FieldB, FieldC))/Count(IF(FieldA = FieldB, FieldC))
Maybe
avg(if(FieldA=FieldB,FieldC))
May be create a flag in the script
LOAD FieldA,
FieldB,
FieldC,
If(FieldA = FieldB, 1, 0) as MatchFlag
FROM....
and then this
Sum({<MatchFlag = {1}>}FieldC)/Count({<MatchFlag = {1}>}FieldC)
Perfect!