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
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
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