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 September 15. Request your voucher.

Reply
_D_D_
New Member

Calculate operation hours / detections per hour per day

Hello,

 

i have the following data which it cannot be changed in power query, all has to be done with DAX.

it contains scans, each scan has a date/time, i wish to calculate the number of scans per hour base upon the first scan of that day and the last scan of that day (operation hours).

 

SkidDetectionTimeSkid_DetectionTimeDetectionIdParkingRightTypeTextVerificationResultDateDetectionTime (bins)dagdeelTime
4254393/07/2023 11:45202307034,8608E+16 FO|EXCEPTION|TEMPORARY_ZONEmonday 3 july 20233/07/2023 11:40D111:40:00
4254703/07/2023 11:46202307034,86081E+16 FINED|NOTPAIDmonday 3 july 20233/07/2023 11:40D111:40:00
4254983/07/2023 11:49202307034,86081E+16 FO|EXCEPTION|HANDICAPmonday 3 july 20233/07/2023 11:40D111:40:00
4264363/07/2023 14:25202307034,86087E+16 FINED|NOTPAIDmonday 3 july 20233/07/2023 14:20D214:20:00
4264393/07/2023 14:25202307034,86087E+16 FINED|NOTPAIDmonday 3 july 20233/07/2023 14:20D214:20:00
4264413/07/2023 14:25202307034,86087E+16 FINED|NOTPAIDmonday 3 july 20233/07/2023 14:20D214:20:00
4264633/07/2023 14:26202307034,86087E+16 FINED|NOTPAIDmonday 3 july 20233/07/2023 14:20D214:20:00
4264763/07/2023 14:28202307034,86087E+16 FO|EXCEPTION|HANDICAPmonday 3 july 20233/07/2023 14:20D214:20:00
4264803/07/2023 14:28202307034,86087E+16 FO|EXCEPTION|HANDICAPmonday 3 july 20233/07/2023 14:20D214:20:00
4264893/07/2023 14:29202307034,86087E+16 FO|EXCEPTION|HANDICAPmonday 3 july 20233/07/2023 14:20D214:20:00
4265403/07/2023 14:31202307034,86087E+16 FO|EXCEPTION|LOAD_UNLOADmonday 3 july 20233/07/2023 14:30D214:30:00
4265774/07/2023 7:24202307044,86127E+16 FINED|NOTPAIDtuesday 4 july 20234/07/2023 7:20D17:20:00
4265804/07/2023 7:24202307044,86127E+16 FINED|NOTPAIDtuesday 4 july 20234/07/2023 7:20D17:20:00
4265834/07/2023 7:24202307044,86127E+16 FO|EXCEPTION|EMERGENCY_SERVICEStuesday 4 july 20234/07/2023 7:20D17:20:00
4266064/07/2023 7:25202307044,86127E+16 FO|EXCEPTION|HANDICAPtuesday 4 july 20234/07/2023 7:20D17:20:00
4266374/07/2023 7:26202307044,86127E+16 FINED|NOTPAIDtuesday 4 july 20234/07/2023 7:20D17:20:00
4266444/07/2023 7:26202307044,86127E+16 FINED|NOTPAIDtuesday 4 july 20234/07/2023 7:20D17:20:00
4266804/07/2023 7:27202307044,86127E+16 FINED|NOTPAIDtuesday 4 july 20234/07/2023 7:20D17:20:00
4292674/07/2023 13:36202307044,86141E+16 FO|EXCEPTION|HANDICAPtuesday 4 july 20234/07/2023 13:30D113:30:00
4292714/07/2023 13:36202307044,86141E+16 FO|EXCEPTION|HANDICAPtuesday 4 july 20234/07/2023 13:30D113:30:00
4292724/07/2023 13:36202307044,86141E+16 FO|EXCEPTION|HANDICAPtuesday 4 july 20234/07/2023 13:30D113:30:00
4295764/07/2023 14:31202307044,86144E+16 InvalidLicensePlatetuesday 4 july 20234/07/2023 14:30D214:30:00
4299875/07/2023 7:22202307054,86183E+16 FO|EXCEPTION|HANDICAPwednesday 5 july 20235/07/2023 7:20D17:20:00
4300125/07/2023 7:22202307054,86183E+16 FINED|NOTPAIDwednesday 5 july 20235/07/2023 7:20D17:20:00
4300145/07/2023 7:22202307054,86183E+16 FINED|NOTPAIDwednesday 5 july 20235/07/2023 7:20D17:20:00

 

thanks in advance

 

 

 

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@_D_D_ , You can try using below mentioned DAX  

 

ScansPerHour =
VAR MinTime =
CALCULATE (
MIN ( 'Table'[SkidDetectionTime] ),
ALLEXCEPT ( 'Table', 'Table'[DetectionId], 'Table'[ParkingRightTypeTextVerificationResultDate] )
)
VAR MaxTime =
CALCULATE (
MAX ( 'Table'[SkidDetectionTime] ),
ALLEXCEPT ( 'Table', 'Table'[DetectionId], 'Table'[ParkingRightTypeTextVerificationResultDate] )
)
VAR TotalScans =
CALCULATE (
COUNTROWS ( 'Table' ),
ALLEXCEPT ( 'Table', 'Table'[DetectionId], 'Table'[ParkingRightTypeTextVerificationResultDate] )
)
VAR TotalHours =
HOUR ( MaxTime - MinTime ) + IF ( MINUTE ( MaxTime - MinTime ) > 0, 1, 0 )
RETURN
DIVIDE ( TotalScans, TotalHours )




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

1 REPLY 1
bhanu_gautam
Super User
Super User

@_D_D_ , You can try using below mentioned DAX  

 

ScansPerHour =
VAR MinTime =
CALCULATE (
MIN ( 'Table'[SkidDetectionTime] ),
ALLEXCEPT ( 'Table', 'Table'[DetectionId], 'Table'[ParkingRightTypeTextVerificationResultDate] )
)
VAR MaxTime =
CALCULATE (
MAX ( 'Table'[SkidDetectionTime] ),
ALLEXCEPT ( 'Table', 'Table'[DetectionId], 'Table'[ParkingRightTypeTextVerificationResultDate] )
)
VAR TotalScans =
CALCULATE (
COUNTROWS ( 'Table' ),
ALLEXCEPT ( 'Table', 'Table'[DetectionId], 'Table'[ParkingRightTypeTextVerificationResultDate] )
)
VAR TotalHours =
HOUR ( MaxTime - MinTime ) + IF ( MINUTE ( MaxTime - MinTime ) > 0, 1, 0 )
RETURN
DIVIDE ( TotalScans, TotalHours )




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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