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: 
Not applicable

Using if vs. coding it in the set analysis

I have a query the first one works but the second one does not.

Works-

if(BOB = 'A',
(sum({$<BOB_age={'$(=DATE(vC))'},age={'>=16 <=25'} >} aging_A) *100),
(sum({$<BOB_age={'$(=DATE(vC))'},age={'>=16 <=25'} >} aging_B) *100))

Does not work:

sum({$<BOB-={'A'},BOB_age={'$(=DATE(vC))'},age={'>=16 <=25'} >} aging_A) *100
+sum({$<BOB={'A'},BOB_age={'$(=DATE(vC))'},age={'>=16 <=25'} >} aging_B) *100

Why?

Thanks.

2 Replies
sunny_talwar

Did you do it opposite?

Sum({$<BOB ={'A'},BOB_age={'$(=DATE(vC))'},age={'>=16 <=25'} >} aging_A) *100

+Sum({$<BOB -={'A'},BOB_age={'$(=DATE(vC))'},age={'>=16 <=25'} >} aging_B) *100

sunny_talwar

Further I would try to use RangeSum() function here to sum them:

RangeSum(Sum({$<BOB = {'A'}, BOB_age = {'$(=DATE(vC))'}, age = {'>=16 <=25'} >} aging_A) * 100, Sum({$<BOB -={'A'}, BOB_age = {'$(=DATE(vC))'}, age = {'>=16 <=25'}>} aging_B) * 100)