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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Barkop_1
Frequent Visitor

Distinctcount based on conditions in multiple columns

Hello, I need dax measure that calculates distinct count of ID column , based on condition form three different columns A,B and C.

Dictinctcount should be calculated when at least of column (A, B, C) has value = 1.

Additionally user can deselect for example column B from calculation, so that then dax should be calculted only on column A, C.

 

Intuitively i would assume it should be something like below, but I am still trying to figure out row/column contex and general DAX rules: 

DistCount = calculate(distinctcount(RawData[ID]) , AND([IsA],RawData[A]=1) || AND([IsB],RawData[B]=1) || AND([IsC],RawData[C]=1) )
 
Przechwytywanie.JPG
1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Barkop_1 

According to your description, you want to "calculates distinct count of ID column , based on condition form three different columns A,B and C.".

Here are the steps you can refer to :
(1)We need to unpivot your table in Power Query Editor :
We need to select the three columns "A,B,C" and click "Unpivot columns":

vyueyunzhmsft_0-1692241008554.png

Then we can change the column name like this:

vyueyunzhmsft_1-1692241043604.png

 

Then we can apply the data to desktop .

 

(2)Then we can create a measure like this:

Measure = CALCULATE( DISTINCTCOUNT('Table'[ID]) , 'Table'[Value] =1)

Then we can get your end result as follows:

vyueyunzhmsft_2-1692241105887.png

 

 

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

2 REPLIES 2
v-yueyunzh-msft
Community Support
Community Support

Hi , @Barkop_1 

According to your description, you want to "calculates distinct count of ID column , based on condition form three different columns A,B and C.".

Here are the steps you can refer to :
(1)We need to unpivot your table in Power Query Editor :
We need to select the three columns "A,B,C" and click "Unpivot columns":

vyueyunzhmsft_0-1692241008554.png

Then we can change the column name like this:

vyueyunzhmsft_1-1692241043604.png

 

Then we can apply the data to desktop .

 

(2)Then we can create a measure like this:

Measure = CALCULATE( DISTINCTCOUNT('Table'[ID]) , 'Table'[Value] =1)

Then we can get your end result as follows:

vyueyunzhmsft_2-1692241105887.png

 

 

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

amitchandak
Super User
Super User

@Barkop_1 , a better idea would to unpivot the column and then use a distinct count on it

Unpivot Data(Power Query): https://youtu.be/2HjkBtxSM0g

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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