Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Rinn
Frequent Visitor

DISTINCT COUNT with condition on measure

Hi,

I have an issue with my DAX calculation. 

 

My visual input table is like that : 

YearID[calculated %] DAX measure
2020a41%
2020b35%
2021a42%
2021b43%
2022b12%
2022c34%

 

I am trying to distinct count the number of IDs that have a calculated % higher than a parameter [user %] (slicer that users can choose themself).

 

So my visual output table would be : (if parameter [user %] = 40%)

YearDistinct count IDs
20201
20212
20220

 

What I tried to do is :

Distinct count IDs = 

CALCULATE(    DISTINCTCOUNT(table[Id]), FILTER(table, [calculated %] > parameter[user %])    )
but my measure is blank when I try to put it in a visual table...
 
Can you help me pls ?
Best Regards.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @Rinn 

 

You can try the following methods.

Measure = CALCULATE(DISTINCTCOUNT('Table'[ID]), FILTER(ALLEXCEPT('Table','Table'[Year]), [calculated %] > SELECTEDVALUE(Parameter[Parameter])))+0

vzhangtinmsft_0-1724119025174.pngvzhangtinmsft_1-1724119045002.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi, @Rinn 

 

You can try the following methods.

Measure = CALCULATE(DISTINCTCOUNT('Table'[ID]), FILTER(ALLEXCEPT('Table','Table'[Year]), [calculated %] > SELECTEDVALUE(Parameter[Parameter])))+0

vzhangtinmsft_0-1724119025174.pngvzhangtinmsft_1-1724119045002.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous , thanks for your reply.

 

Actually, for your example, I tried with my real DAX measure [calculated %] (sorry for not posting it earlier) which is :

calculated % =
var _prev= CALCULATE(SUM('Table'[Value]), PREVIOUSYEAR('Table'[Year]))
RETURN
DIVIDE(SUM('Table'[Value]), _prev)-1
 
And I did not work unfortunately.
Rinn_0-1724146273589.png

 

Do you know why ?
Edit : the variable _prev seems to be the reason of the disfunctioning of the calculation
Regards.
Rinn
Frequent Visitor

The response of @Anonymous is a good solution.

For my particular problem, I separated calculated % into 3 measures :

1. CALCULATE(SUM('Table'[Value]), PREVIOUSYEAR('Table'[Year]))
2. SUM('Table'[Value]
3. DIVIDE(1., 2.)-1
 
And it works well.
 
Thank you !
 
Regards
AmiraBedh
Super User
Super User

Try to create a query new blank query and type = MYPARAMETER, 

Than you can reference in columns/dax measures

https://community.fabric.microsoft.com/t5/Desktop/How-to-reference-a-parameter-to-a-DAX-function/m-p...

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.