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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
AndreasB
Regular Visitor

Count Records Between Start date/time and End date/time (for every second of the day(s))

Hi,
I need some help with a formula in DAX for a measure.

data:

_idStart Date/TimeEnd Date/Time
63c13320c47798de09659e2c13.01.2023 10:19:0813.01.2023 10:19:31
63c13320c47798de09659d0913.01.2023 10:20:1813.01.2023 10:20:52
63c13320c47798de09659d1f13.01.2023 10:23:2813.01.2023 10:24:54
63c13320c47798de09659d2013.01.2023 10:19:2013.01.2023 10:20:10
63c13320c47798de09659d3513.01.2023 10:18:3513.01.2023 10:19:15
63c13320c47798de09659db913.01.2023 10:18:2213.01.2023 10:19:54
63c13320c47798de09659de813.01.2023 10:19:3013.01.2023 10:20:00
63c13320c47798de09659e0913.01.2023 10:20:0113.01.2023 10:20:26
63c13320c47798de09659cbc13.01.2023 10:20:4013.01.2023 10:26:45


And I have a date/time table (similar to a date table but with a record per second instead of a record per day):
[D/Ts]

date/time
13.01.2023 10:19:16
13.01.2023 10:19:17
13.01.2023 10:19:18
13.01.2023 10:19:19
13.01.2023 10:19:20
13.01.2023 10:19:21
13.01.2023 10:19:22
13.01.2023 10:19:23
13.01.2023 10:19:24

 

What I'd need is a measure for each [D/Ts].'date/time' that count([data].'id') where [D/Ts].'date/time' >= [data].'Start date/time' AND [D/Ts].'date/time' <= [data].'End date/time':

date/time required result
13.01.2023 10:19:162
13.01.2023 10:19:172
13.01.2023 10:19:182
13.01.2023 10:19:192
13.01.2023 10:19:203
13.01.2023 10:19:213
13.01.2023 10:19:223
13.01.2023 10:19:233
13.01.2023 10:19:243


Thanks in advance for any help getting this solved.

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

NewMeasure=VAR _Second=MAX('D/Ts'[date/time]) RETURN COUNTROWS(FILTER(Data,Data[Start Date/Time]<=_Second&&Data[End Date/Time]>=_Second))

View solution in original post

2 REPLIES 2
AndreasB
Regular Visitor

Thanks a lot @wdx223_Daniel  - this was exactly what I was trying to do. 

wdx223_Daniel
Super User
Super User

NewMeasure=VAR _Second=MAX('D/Ts'[date/time]) RETURN COUNTROWS(FILTER(Data,Data[Start Date/Time]<=_Second&&Data[End Date/Time]>=_Second))

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.