Forum Discussion
How to distinct count with filter - counting measures
- Anonymous4 years ago
Hi Anonymous ,
Oh ,got it!
I built another data sample :
And the [Chart] is a measure not column:
Chart = IF(MAX('Table'[Column1])>10,"A","B")Then please try:
Count A = var _t=SUMMARIZE('Table',[Index],"Chart",[Chart]) return COUNTROWS(FILTER(_t,[Chart]="A"))Count B = var _t=SUMMARIZE('Table',[Index],"Chart",[Chart]) return COUNTROWS(FILTER(_t,[Chart]="B"))Output:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous can you give an example of what you mean when you say "its not counting how many have A, B, C"?
Your code is working fine in my testing.
CountA =
CALCULATE(
DISTINCTCOUNT('Table'[Item]),
FILTER('Table', [Chart] = "A")
)
CountB =
CALCULATE(
DISTINCTCOUNT('Table'[Item]),
FILTER('Table', [Chart] = "B")
)
- Anonymous4 years agoNot applicable
I did each measure individually, maybe thats why. Im getting a red underline right now with CountB and CountC, How would I write this in full?
- Anonymous4 years agoNot applicable
Anonymous I'm sorry I wasn't clear - those should be written as separate measures. I've edited to clarify.
- Anonymous4 years agoNot applicable
Does it help to point out that 'chart' is a measure from a datediff measure then an if statement
- Anonymous4 years agoNot applicable
Yes, that would've been very helpful to know beforehand. Your approach using CALCULATE is not going to work then.
- Anonymous4 years agoNot applicable
Oh I see, do you have suggestions on what other approach I can try?