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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
CanCan
Contributor
Contributor

Use If()+ Accumulative+ Count Distinct

Hi Experts,

I am trying to create an accumulative chart with some IF conditions but the result is not accumulated properly. 

My formula:

IF('$(vProduct)'='A',rangesum(above(Count(distinct {<[Product Type]={‘A’}>} Customer ID)),0,rowno()),

IF('$(vProduct)'=’B’,rangesum(above(Count(distinct {<[ Product Type]={‘B’ }>}customer ID)),0,rowno()),

IF('$(vProduct)'='C',rangesum(above(Count(distinct {<[ Product Type]={'C'}>}customer ID)),0,RowNo()),

               IF('$(vProduct)'='ALL',rangesum(above(count(distinct(customer ID))))))))

 

My result will be something like below if i use above expression.😢

wrong accmulative.PNG

Appreciate if you could enlighten me.

Thanks!

Labels (6)
1 Solution

Accepted Solutions
MayilVahanan
MVP
MVP

Hi

$(vProduct) -- is selected by user in filters? ie. At a time, one if condition will be executed? 

Try like below

=rangesum(above(IF('$(vProduct)'='A',Count(distinct {<[Product Type]={‘A’}>} Customer ID),

IF('$(vProduct)'=’B’,Count(distinct {<[ Product Type]={‘B’ }>}customer ID),

IF('$(vProduct)'='C', Count(distinct {<[ Product Type]={'C'}>}customer ID),

                IF('$(vProduct)'='ALL',count(distinct(customer ID)))))),0,rowno(Total)))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

4 Replies
sidhiq91
Specialist II
Specialist II

@CanCan  Can you please provide some sample data?

MayilVahanan
MVP
MVP

Hi

$(vProduct) -- is selected by user in filters? ie. At a time, one if condition will be executed? 

Try like below

=rangesum(above(IF('$(vProduct)'='A',Count(distinct {<[Product Type]={‘A’}>} Customer ID),

IF('$(vProduct)'=’B’,Count(distinct {<[ Product Type]={‘B’ }>}customer ID),

IF('$(vProduct)'='C', Count(distinct {<[ Product Type]={'C'}>}customer ID),

                IF('$(vProduct)'='ALL',count(distinct(customer ID)))))),0,rowno(Total)))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
CanCan
Contributor
Contributor
Author

@MayilVahanan  Thanks for the big help!!!!! It worked!!!!!😊 

MayilVahanan
MVP
MVP

Hi

Happy to know that, Can you please close the thread? 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.