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
prattja9
Frequent Visitor

Calculate number of distinct dates in a table with conditions in other columns

Greetings, 

I have a table of data about tests. Individual ID's can take more than one test in a given day. I'm trying to compute a column that calculates the number of distinct dates in the table per ID. So for example:

 

ID

Subject

Date

1

Math

1/1/2022

2

Science

2/2/2022

2

Math

2/2/2022

3

English

3/1/2022

3

Math

3/1/2022

3

Math

4/1/2022

 

With my expect result being: 

 

ID

Subject

Date

 

Unique Dates by ID

1

Math

1/1/2022

 

1

2

Science

2/2/2022

 

1

2

Math

2/2/2022

 

1

3

English

3/1/2022

 

2

3

Math

3/1/2022

 

2

3

Math

4/1/2022

 

2

 

I've tried various combinations using calculate, summarize, and sumx. And I can get the value I expect in a visual by using distinct count, but I can't get it to work with DAX. 

 

Thanks!

1 ACCEPTED SOLUTION
rsbin
Super User
Super User

@prattja9 ,

Your Calculated Column is:

UniqueDatesbyID = CALCULATE( DISTINCTCOUNT( [Date] ),
                             ALLEXCEPT( Tests, Tests[ID] ))

Trust this is what you are looking for.

Regards,

View solution in original post

1 REPLY 1
rsbin
Super User
Super User

@prattja9 ,

Your Calculated Column is:

UniqueDatesbyID = CALCULATE( DISTINCTCOUNT( [Date] ),
                             ALLEXCEPT( Tests, Tests[ID] ))

Trust this is what you are looking for.

Regards,

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.