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: 
paulwalker
Creator III
Creator III

Compare with Attribute on same field

Hi Community,

Facing issue with expression,  I have similar data like below 

If it is same CODE for EMP (N and Y), they have to calculate sum(SALARY)

trying below expression, but not working..

=IF(AGGR(ONLY({<EMP={'N'}>}CODE), CODE) = AGGR(ONLY({<EMP={'Y'}>}CODE), CODE), SUM(SALARY))

CODEEMPSALARY
AN100
AY200
BN300
CN400
DN500
DY600

Output:

CODESALARY
A300
D1100

Thanks in advance

Labels (1)
3 Replies
agigliotti
Partner - Champion
Partner - Champion

Hi @paulwalker ,

You could try with the below expression:
=Sum( if( count( distinct EMP ) = 2, SALARY ) )

with CODE as dimension.

I hope it can helps.

Best Regards

Andrea

edwin
Master II
Master II

try this:
=sum({<CODE=p({<EMP={'Y'}>}CODE)>}SALARY)

which means if there exists a CODE where EMP=Y, sum it

marcus_sommer

Another one:

SUM({<EMP={'N'}> * <EMP={'Y'}>} SALARY)

- Marcus