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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Gerbil
Helper I
Helper I

How to count all events happening 24hrs from an event?

I have a list of events with their begin and end times like so:

 

Ref NumStartEnd
1141/1/2023 0:051/1/2023 6:29
8911/1/2023 19:061/1/2023  19:53
4161/1/2023 22:061/1/2023  22:46
3101/1/2023 23:101/1/2023 23:02
2001/2/2023 0:141/2/2023 3:07
9261/2/2023 3:191/2/2023 3:36
3981/2/2023 6:191/2/2023 6:41
6081/3/2023 10:251/3/2023 10:18
401/3/2023 13:271/3/2023 13:08
4031/3/2023  16:331/3/2023 16:35
6681/3/2023 20:091/3/2023 20:15
8541/4/2023 1:091/4/2023 2:01
2501/4/2023 5:171/4/2023 5:12

 

I want to count all the events that are within 24hrs after the event time like so:

 

Ref NumStartEndCount
1141/1/2023 0:051/1/2023 6:294
8911/1/2023 19:061/1/2023  19:536
4161/1/2023 22:061/1/2023  22:465
3101/1/2023 23:101/1/2023 23:024
2001/2/2023 0:141/2/2023 3:073
9261/2/2023 3:191/2/2023 3:362
3981/2/2023 6:191/2/2023 6:411
6081/3/2023 10:251/3/2023 10:185
401/3/2023 13:271/3/2023 13:084
4031/3/2023  16:331/3/2023 16:353
6681/3/2023 20:091/3/2023 20:153
8541/4/2023 1:091/4/2023 2:012
2501/4/2023 5:171/4/2023 5:121

 

 

I was able to do this in excel using this function:

 

=SUMPRODUCT(--($E$6:$E$18<(E6+1)),--($E$6:$E$18>E6))+1

 

where E is the Start column. But I cannot figure how to do this in PowerBI.

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Gerbil 

 

You can try the following methods.
Column:

Start+24h = [Start]+1
Count = 
CALCULATE ( COUNT ( 'Table'[Ref Num] ),
    FILTER ( ALL ( 'Table' ),
        [Start] >= EARLIER ( 'Table'[Start] )
            && [Start] <= EARLIER ( 'Table'[Start+24h] ) ) )

vzhangti_0-1682045009664.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @Gerbil 

 

You can try the following methods.
Column:

Start+24h = [Start]+1
Count = 
CALCULATE ( COUNT ( 'Table'[Ref Num] ),
    FILTER ( ALL ( 'Table' ),
        [Start] >= EARLIER ( 'Table'[Start] )
            && [Start] <= EARLIER ( 'Table'[Start+24h] ) ) )

vzhangti_0-1682045009664.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.