4 Replies Latest reply: Dec 7, 2017 4:57 AM by Bruno Paulo

# Compare 2 strings in set analysis

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?

Best Regards

Bruno Paulo

• ###### Re: Compare 2 strings in set analysis

Try this may be?

= Sum(IF(FieldA = FieldB, FieldC))/Count(IF(FieldA = FieldB, FieldC))

• ###### Re: Compare 2 strings in set analysis

Maybe

avg(if(FieldA=FieldB,FieldC))

• ###### Re: Compare 2 strings in set analysis

May be create a flag in the script

FieldB,

FieldC,

If(FieldA = FieldB, 1, 0) as MatchFlag

FROM....

and then this

Sum({<MatchFlag = {1}>}FieldC)/Count({<MatchFlag = {1}>}FieldC)

• ###### Re: Compare 2 strings in set analysis

Perfect!