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! Learn more

Reply
larsvillaume
Frequent Visitor

DistinctCount on date field returns number of days in calendar year instead of number in dataset

Hi,

I have imported a csv file as dataset. The dataset contains incident records for 6 months and it has date field of type date. I need a number of days in the dataset i.e. a number of days that has an incident record. I have tried to create a measure using DISTINCTCOUNT but it returns 365 as value i.e. the number of days in the calendar year instead of just the dates for the incident records that exist in the dateset (6 months) .

 

"Days with incidents = DISTINCTCOUNT(('DataSet All Incidents Last 6 Months'[Created Date].[Date]))"

 

I have tried using FILTER to only include rows from the dateset but that doesn't give the right result either.

 

br

Lars

 

 
 
2 ACCEPTED SOLUTIONS
Mariusz
Community Champion
Community Champion

Hi @larsvillaume 

 

Try the below, without .[Date]

Days with incidents = DISTINCTCOUNT( 'DataSet All Incidents Last 6 Months'[Created Date] )

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

View solution in original post

Hi @larsvillaume 

 

When you referring to .[date] you are in fact referring to a hidden date dimension that will create a min of a full year that's why you see 365, to avoid it you can split you DateTime in the Query Editor or model and then count distinct on the date field

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

View solution in original post

4 REPLIES 4
Mariusz
Community Champion
Community Champion

Hi @larsvillaume 

 

Try the below, without .[Date]

Days with incidents = DISTINCTCOUNT( 'DataSet All Incidents Last 6 Months'[Created Date] )

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Hi @Mariusz 

 

Thanks but that (without .[date]) gives a number equal to number of rows in the dataset. The dataset looks like this in query editor. The Created Date type is of "Date/Time". There incidents is from may to november so if incidents is registered every day in those 6 months I should get a number of around 180 distinct days.

 

2019-11-12 09_24_27-DataSet All Incidents Last 6 Months.csv - Excel.png

 

br

Lars

Hi @larsvillaume 

 

When you referring to .[date] you are in fact referring to a hidden date dimension that will create a min of a full year that's why you see 365, to avoid it you can split you DateTime in the Query Editor or model and then count distinct on the date field

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

Thx @Mariusz ,

 

I duplicated the "Created Date" column and changed the type to just Date, so now I get the right number. I guess using split in the quey is a more proper ways of acheiving the goal so will try that also.

 

br

Lars

Helpful resources

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

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