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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
kenshaw
New Member

Help with distinctcount based on a field with two cases for if statement

I'm trying to perform a distinctcount based on a field that has two set of factors:

1. First distinctcount is when the field only matches value "X".  If it does, I'd like to multiply this distinctcount by (1-r) where r is a %.

2. Second distinctcount is when the field matches all other values but not "X".  If it does, I'd like to just return the distinctcount for those but not include the distinctcount from "X".

 

Am I able to do this with one measure?

1 REPLY 1
some_bih
Super User
Super User

Hi @kenshaw your measures could be something like below, adjust part 'YourTable'[ColumnX] to your names
FirstDistinctCountWeighted =
VAR CountX =

CALCULATE(DISTINCTCOUNT('YourTable'[ColumnX]), 'YourTable'[ColumnX] = "X")
RETURN
IF (CountX > 0, CountX * (1 - (YOUR_WEIGHT_PERCENTAGE / 100)), 0)

 

SecondDistinctCount =
VAR CountAllButX =

CALCULATE(DISTINCTCOUNT('YourTable'[ColumnX]), NOT('YourTable'[ColumnX] = "X"))
RETURN
IF (CountAllButX > 0, CountAllButX, 0)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors