Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
paulwalker
Creator II
Creator II

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