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

Announcements
Posting on Qlik Community is temporarily paused. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
ValeriaBonini
Partner - Creator
Partner - Creator

Count distinct based on a Measure

Hi, I have a master measure calculated like this:

DELTA =     (p2*q)-(p1*q)

 

then I would like to have  a KPI with a master measure like this:

#positive rows =    count(distinct {<DELTA={">0"}>} ID)     but this doesn't work.

How can I do that?

Labels (5)
1 Solution

Accepted Solutions
Kushal_Chawda
MVP
MVP

@ValeriaBonini  try below

 

count(distinct {<ID={" =((p2*q)-(p1*q))>0"}>} ID)

View solution in original post

5 Replies
sandeep-singh
Creator II
Creator II

Remove the text "#positive rows =" from your expression. If you need, you can add #positive rows in the label

ValeriaBonini
Partner - Creator
Partner - Creator
Author

yes, the "#positive rows =" is not in my master measures, I wrote this only to explain my problem better...

ValeriaBonini
Partner - Creator
Partner - Creator
Author

master measures number 1: DELTA

 

(p2*q)-(p1*q)

 

Master measure number2: #positive rows 

 

   count(distinct {<DELTA={">0"}>} ID)  

Or
MVP
MVP

Set modifiers can only be used on a field, so you will not be able to use it on a measure in this manner. You can however spell it out using an If() statement, e.g. Count(distinct if((p2*q)-(p1*q) > 0, ID)). Note that you may need to use aggr() if you want this calculated on anything but a per-single-row level.

You could also reframe this as a search on a field (ID in your case), but as I was editing to get the syntax right Kushal_Chadwa posted the correct one, so go with that one.

 

Kushal_Chawda
MVP
MVP

@ValeriaBonini  try below

 

count(distinct {<ID={" =((p2*q)-(p1*q))>0"}>} ID)