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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Distinct Count of Dates In 1 Hour Range

Hello,

 

I'm having some issues getting a Distinct Count of dates with some dates that differ by a few minutes each way.

 

I have 2 tables:

 

Status - StatusID

 

Results - ResultID, StatusID, CreatedOn

 

One status has many results.

 

I might have a status with ID: 1 and 5 results containing StatusID 5.

 

I was doing a DISTINCTCOUNT on CreatedOn to get all of the results grouped by date. However, the dates can differ by a few minutes each way, so I might have the following:

 

6/15/2018 6:45:02 PM

6/15/2018 6:43:02 PM

6/15/2018 6:48:05 PM

6/15/2018 6:41:02 PM

 

A DistinctCount on these rows would bring back 4. However, what I want is a filter to count records that are within a 1 hour range (30 minutes each side) as one. So this would bring back a result of 1 instead of 4.

 

I tried through the Data model to round the hour up/down but then there would be issues of times close to the hour. I have a feeling I might need to do COUNTROWS with some condition but I'm struggling to see how to compare values to the previous one?

 

Any help would be greatly appreciated.

 

Thanks,

 

Chris

1 REPLY 1
Greg_Deckler
Super User
Super User

Soooo...how exactly do you want the grouping to occur? Do you want everything in HOUR 6 to be grouped together or does hour 6 need to get everything from 5:30 - 6:30?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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