Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
brunopaulo
Partner - Creator II
Partner - Creator II

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?
Thanks in advance

Best Regards

Bruno Paulo

1 Solution

Accepted Solutions
sunny_talwar

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)

View solution in original post

4 Replies
vishsaggi
Champion III
Champion III

Try this may be?

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

Anonymous
Not applicable

Maybe

avg(if(FieldA=FieldB,FieldC))

sunny_talwar

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)

brunopaulo
Partner - Creator II
Partner - Creator II
Author

Perfect!