Forum Discussion
Lucky_BI
3 years agoFrequent Visitor
Calculate time by day
How do I add up the duration (Time Check out - Time Check in) of each name based on the date of the day excluding him from a different outlet with DAX?
Example:
- Name : Mike
- Dates:
- 20/03/2023
- Outlet A: 17:00:00 - 08:00:00 = 09:00:00
- Outlet B: 16:00:00 - 08:00:00 = 08:00:00
- 21/03/2023
- Outlet C: 16:30:00 - 08:00:00 = 08:30:00
- 20/03/2023
So, Mike's Duration for 20/03/2023 is 17:00:00 Hours. Meanwhile, Mike's duration for 21/03/2023 is 08:30:00 Hours
Download file: Time.xlsx
Thank you for your help
Hi Lucky_BI
DateTime format cannot display times more than 24 hours. This has to be a decimal number or custom formatted string. Please refer to attached sample file with the proposed solutionTotal Hours = SUMX ( SUMMARIZE ( 'Table', 'Table'[Name], 'Table'[Date] ), CONVERT ( SUMX ( CALCULATETABLE ( 'Table' ), 'Table'[Time Check Out] - 'Table'[Time Check In] ), DOUBLE ) )
4 Replies
- tamerj1
Community Champion
Hi Lucky_BI
DateTime format cannot display times more than 24 hours. This has to be a decimal number or custom formatted string. Please refer to attached sample file with the proposed solutionTotal Hours = SUMX ( SUMMARIZE ( 'Table', 'Table'[Name], 'Table'[Date] ), CONVERT ( SUMX ( CALCULATETABLE ( 'Table' ), 'Table'[Time Check Out] - 'Table'[Time Check In] ), DOUBLE ) )