Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join us at the Cloud Data and Analytics Tour! REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
brunopaulo
Partner
Partner

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))

atkinsow
Specialist II
Specialist II

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)

View solution in original post

brunopaulo
Partner
Partner
Author

Perfect!