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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
GianPaolo
Frequent Visitor

DISTINCTCOUNT on factTable based on 2 Criteria

Hi Everyone!

 

I am quite new to DAX. I made my model really simple in the attached file .xlsx

I would like to compute a DISTINCTCOUNT of the FACT_TABLE[CUSTOMER ID] based on the following criteria:

 

Total Values for each "Customer ID" in the "1 SEMESTER" = 0 AND Total Values for each "Customer ID" in the 2 SEMESTER >  0

In this example CUSTOMER ID = 1 AND CUSTOMER ID = 3 are ok and they should be counted in the DISTINCTCOUNT because both have 1 semester = 0 and 2 semester > 0

 

https://filetransfer.io/data-package/47cqvbpL#link

 

thanks in advance

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1654549969941.png

 

For fun only, a showcase of powerful Excel worksheet formula,

CNENFRNL_1-1654550106706.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1654549969941.png

 

For fun only, a showcase of powerful Excel worksheet formula,

CNENFRNL_1-1654550106706.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Thank you for your answer!! Unofortunately I am using Power Pivot and the TREATAS is not provided....

I think it is really a good idea the Excel flag you did...

DO you think would be possibile to add a calculated column in the model for doing the same thing as you did in the Excel Worksheet?

Thanks a lot!

johnt75
Super User
Super User

Num customers =
var semester1 = CALCULATETABLE( VALUES('Table'[Customer ID]), 
TREATAS( { ("Semester 1", 0)}, 'Table'[Semester], 'Table'[Values Euro]) )
var semester2 = CALCULATETABLE( VALUES('Table'[Customer ID]), 'Table'[Semester] = "Semester 2" && 'Table'[Values Euro] > 0)
return DISTINCTCOUNT(UNION(semester1, semester2))

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.