Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count(Distinct()) with condition

Hi!

I want to use COUNT(DISTINCT()) to calculate the number of clients that bought a certain product. I am using this formula, but the numbers are weird, it's not correct.

IF(CPRODUS='A19', COUNT(DISTINCT(CCLIENT)))

What to i do wrong?

1 Solution

Accepted Solutions
manas_bn
Creator
Creator

Hi Laura,

I hope this is what you are looking for. Here goes -

You can use

IF(CPRODUS='A19', COUNT(DISTINCT CCLIENT)) OR

Count({$<CPRODUS={'A19'}>} distinct CCLIENT) OR // value changes based on selections

Count({1<CPRODUS={'A19'}>} distinct CCLIENT) // value remains same regardless of selections

But the correct value will still depend on which chart you are using and what dimensions...

Cheers,

Manas

View solution in original post

3 Replies
manas_bn
Creator
Creator

Hi Laura,

I hope this is what you are looking for. Here goes -

You can use

IF(CPRODUS='A19', COUNT(DISTINCT CCLIENT)) OR

Count({$<CPRODUS={'A19'}>} distinct CCLIENT) OR // value changes based on selections

Count({1<CPRODUS={'A19'}>} distinct CCLIENT) // value remains same regardless of selections

But the correct value will still depend on which chart you are using and what dimensions...

Cheers,

Manas

rajeshvaswani77
Specialist III
Specialist III

Hi,

Can you try this

count(if(CPRODUS='A19',DISTINCT(CCLIENT)))

thanks,

Rajesh Vaswani

Not applicable
Author

Thanks, guys, it works now.