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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Lakka00
Regular Visitor

Time totals

I have a table which records the number of times someone is late and the time. I need it to be a count of lates and then in the last column the total time for the rows counted.

 

Below is how it is appearing, each colour represents the same person, there should ideally be one entry for each person.

Lakka00_0-1714471649046.png

 

12 REPLIES 12
PhilipTreacy
Super User
Super User

Hi @Lakka00 

 

Download PBIX file with the example below

 

This is done more easily in Power Query than in DAX.  The DAX solution is very fiddly.

 

Reason being is your Late Length values will be treated as a time, rather than a duration which is what you want.  DAX doesn't have the concept of a duration.

 

Power Query does.  In PQ you can convert a time column to text, and then convert that to a duration.

 

Duplicate your data table, you can then group the rows by the Name and SUM the durations (note that I didn't enter the data exactly the same as yours so these Late Durations totals will be different to yours)

 

latedur.png

 

late-duration.png

 

You've now got 2 tables.  One with the original data and one with the total late duration calculation.  Load these to PBI, create a relationship between the 2 based on Name.

 

This measure will give the Late Count

 

Count Lates = CALCULATE(COUNTROWS('DataTable2'), FILTER(ALL('DataTable2'), 'DataTable2'[Name] = SELECTEDVALUE('DataTable'[Name])))

 

latecounts.png

 

Regards

 

Phil

 

 

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi, I ave tried this but I get an error in the sum or duration column. 

Lakka00_0-1714482121163.png

Lakka00_1-1714482145003.png

I may be wrong but it doesn't seem to be converting to duration.

 

@Lakka00 

 

You can't add times.  You need to convert the time column to text and then convert to duration. 

 

Did you check my example file to see what I did?

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi, yes sorry. I am fairly new to this, I have followed the steps but I keep getting errors. I don't fully undertsnad the relationshiop access, But I managed to get it linked, however, it is in decimal form and the data is wrong, some peoples data is completely missing. Is there anyway you could break it down abit more so I can see where I am going wrong.

 

Lakka00_0-1714488331297.png

 

@Lakka00 

 

No worries.

 

Can you please supply some of your data (or the PBIX file) - change any personal/private data.

 

If I can see the data you are working with I can figure out what is going wrong.

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Sure, unfortunately I cannot attach files but here is a table: 

 

TitleLog off TimeReturn TimeCurrently_on_breakLengthLunchCreatedTime stopLate?Late_Length
Jack11:10:2811:31:02NO00:20:34Break01/04/2024 11:1000/01/1900 11:30  
Jack14:29:5715:09:58NO00:40:01Lunch01/04/2024 14:2900/01/1900 15:09  
Jack16:46:1317:06:33NO00:20:19Break01/04/2024 16:4600/01/1900 17:06  
Jess10:50:4511:10:23NO00:19:38Break02/04/2024 10:5000/01/1900 11:10  
Ben11:55:4112:34:36NO00:38:54Lunch02/04/2024 11:5500/01/1900 12:35  
Jess12:30:5313:12:03NO00:41:10Lunch02/04/2024 12:3000/01/1900 13:10yes00:01:10
Chris13:13:2213:29:53NO00:16:31Break02/04/2024 13:1300/01/1900 13:33  
Jess14:56:4815:14:26NO00:17:38Break02/04/2024 14:5600/01/1900 15:16  
Chris15:12:3015:45:26NO00:32:56Lunch02/04/2024 15:1200/01/1900 15:52  
Chris16:52:1217:12:53NO00:20:39Break02/04/2024 16:5200/01/1900 17:12  
Jess10:40:1911:01:41NO00:21:23Break03/04/2024 10:4000/01/1900 11:00yes00:01:23
Jack11:00:2811:20:30NO00:20:01Break03/04/2024 11:0000/01/1900 11:20  
Ben11:51:4312:10:10NO00:18:27Break03/04/2024 11:5100/01/1900 12:11  
Jess11:52:2412:31:22NO00:38:58Lunch03/04/2024 11:5200/01/1900 12:32  
Jack12:32:5413:12:55NO00:40:00Break03/04/2024 12:3200/01/1900 12:52yes00:20:00
Chris13:16:3613:28:02NO00:11:26Break03/04/2024 13:1600/01/1900 13:36  
Ben14:20:5214:57:27NO00:36:35Lunch03/04/2024 14:2000/01/1900 15:00  
Jess14:32:5614:50:22NO00:17:26Break03/04/2024 14:3200/01/1900 14:52  
Jack14:52:2215:12:58NO00:20:36Break03/04/2024 14:5200/01/1900 15:12  
Chris15:10:0115:49:36NO00:39:34Lunch03/04/2024 15:1000/01/1900 15:50  
Chris16:52:0717:10:19NO00:18:11Break03/04/2024 16:5200/01/1900 17:12  
Ben16:52:4817:11:07NO00:18:18Break03/04/2024 16:5200/01/1900 17:12  
Jess10:41:0111:00:20NO00:19:19Break04/04/2024 10:4100/01/1900 11:01  
Ben11:50:0412:09:53NO00:19:48Break04/04/2024 11:5000/01/1900 12:10  
Jack11:57:4012:17:43NO00:20:03Break04/04/2024 11:5700/01/1900 12:17  
Jess12:30:1813:08:54NO00:38:35Lunch04/04/2024 12:3000/01/1900 13:10  
Chris13:10:2413:31:17NO00:20:52Break04/04/2024 13:1000/01/1900 13:30  
Ben14:29:4615:08:11NO00:38:24Lunch04/04/2024 14:2900/01/1900 15:09  
Jess14:36:3514:53:36NO00:17:01Break04/04/2024 14:3600/01/1900 14:56  
Chris15:20:1715:54:39NO00:34:22Lunch04/04/2024 15:2000/01/1900 16:00  
Ben16:57:2717:09:31NO00:12:03Break04/04/2024 16:5700/01/1900 17:17  
Chris17:33:4318:21:54NO00:48:10Break04/04/2024 17:3300/01/1900 17:53yes00:28:10
Jess10:46:5611:06:25NO00:19:28Break05/04/2024 10:4600/01/1900 11:06  
Ben11:53:1512:12:03NO00:18:48Break05/04/2024 11:5300/01/1900 12:13  
Jack11:53:2912:16:02NO00:22:33Break05/04/2024 11:5300/01/1900 12:13yes00:02:33
Jess12:30:0813:09:32NO00:39:23Lunch05/04/2024 12:3000/01/1900 13:10  
Chris13:10:1913:31:50NO00:21:30Break05/04/2024 13:1000/01/1900 13:30yes00:01:30
Jack14:32:4015:12:55NO00:40:14Lunch05/04/2024 14:3200/01/1900 15:12  
Ben14:45:0815:11:18NO00:26:09Break05/04/2024 14:4500/01/1900 15:05yes00:06:09
Jess15:00:3315:17:39NO00:17:06Break05/04/2024 15:0000/01/1900 15:20  
Ben15:11:4315:24:09NO00:12:26Break05/04/2024 15:1100/01/1900 15:31  
Chris15:13:4115:52:37NO00:38:55Lunch05/04/2024 15:1300/01/1900 15:53  
Ben16:53:4617:12:16NO00:18:30Break05/04/2024 16:5300/01/1900 17:13  
Jack16:54:1017:14:48NO00:20:37Break05/04/2024 16:5400/01/1900 17:14  
Chris17:15:5017:35:29NO00:19:39Break05/04/2024 17:1500/01/1900 17:35  
Jack11:28:5011:48:58NO00:20:07Break06/04/2024 11:2800/01/1900 11:48  
Jack13:49:3913:49:41NO00:00:01Break06/04/2024 13:4900/01/1900 14:09  
Jack13:49:4114:30:11NO00:40:29Lunch06/04/2024 13:4900/01/1900 14:29  
Jack16:09:4316:30:24NO00:20:41Break06/04/2024 16:0900/01/1900 16:29  
Chris10:50:3911:08:52NO00:18:13Break08/04/2024 10:5000/01/1900 11:10  
Chris12:51:2613:30:44NO00:39:18Lunch08/04/2024 12:5100/01/1900 13:31  
Jack13:12:3713:18:59NO00:06:22Break08/04/2024 13:1200/01/1900 13:32  
Jack13:19:0013:39:09NO00:20:08Break08/04/2024 13:1900/01/1900 13:39  
Ben13:30:0013:31:18NO00:01:17Break08/04/2024 13:3000/01/1900 13:50  
Ben13:50:0414:09:51NO00:19:46Break08/04/2024 13:5000/01/1900 14:10  
Chris15:30:0515:48:17NO00:18:11Break08/04/2024 15:3000/01/1900 15:50  
Jack15:38:5016:19:04NO00:40:13Lunch08/04/2024 15:3800/01/1900 16:18  
Ben15:54:4616:32:10NO00:37:23Lunch08/04/2024 15:5400/01/1900 16:34  
Jack17:12:1317:33:19NO00:21:05Break08/04/2024 17:1200/01/1900 17:32yes00:01:05
Ben17:33:5617:52:52NO00:18:56Break08/04/2024 17:3300/01/1900 17:53  
James11:30:5111:50:36NO00:19:44Break09/04/2024 11:3000/01/1900 11:50  
Chris13:10:4613:27:55NO00:17:07Break09/04/2024 13:1000/01/1900 13:30  
Jess13:31:3913:49:34NO00:17:55Break09/04/2024 13:3100/01/1900 13:51  
Ben13:34:4513:53:21NO00:18:35Break09/04/2024 13:3400/01/1900 13:54  
James13:50:5914:40:52NO00:49:52Lunch09/04/2024 13:5100/01/1900 14:30yes00:09:52

 

 

Thanks @Lakka00 

 

Here's a PBIX file with the solution

 

latep.png

 

I had to modify the DAX measure for the Late Count as your column names were different to what I originally had

 

Count Lates = CALCULATE(COUNTROWS('DataTable'), FILTER(ALL('DataTable'), 'DataTable'[Late?] ="yes" && 'DataTable'[Title] = SELECTEDVALUE('DataTable'[Title])))

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi, thank you. However I cannot open the file due to incompatible version types, I will try get mine updated but I am assuming I will not be able to due to IT restrictions. 

Hi @Lakka00 ,

I think your solution is great, @PhilipTreacy . It worked like a charm! I think you can update your Power BI Desktop version and try to open the .pbix file provided by PhilipTreacy below.

 

 

Best Regards

Yilong Zhou

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

Uzi2019
Super User
Super User

Hi @Lakka00 

You can simply take your Late_length column change aggragation to count.

Uzi2019_0-1714472713654.png

 


In your table it will be just Employee name and Count(Late_length) 

 

I hope I answered your question!

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Hi, thank you but the 2nd column is the count of lates, I need the 3rd column to be the total amount of time late, for example, the first person was late 3 times, column 2 should show 3 lates and the last column should show 00:07:32 (Total time late of those 3 occasions)

hi @Lakka00 

Can you try this dax present in the post.
https://community.fabric.microsoft.com/t5/Desktop/Working-with-time-duration/m-p/3674090

 

Or try this Dax

 

SumTalkTime =

VAR TotalSeconds=SUMX('Table Name',HOUR('Table Name'[Column])*3600+MINUTE('Table Name'[Column])*60+SECOND('Table Name'[Column]))
VAR Days =TRUNC(TotalSeconds/3600/24)
VAR Hors = TRUNC((TotalSeconds-Days*3600*24)/3600)
VAR Mins =TRUNC(MOD(TotalSeconds,3600)/60)
VAR Secs = MOD(TotalSeconds,60)
return IF(DAYS=0,"",IF(DAYS>1,DAYS&"days ",Days&"day"))&IF(Hors<10,"0"&Hors,Hors)&":"&IF(Mins<10,"0"&Mins,Mins)&":"&IF(Secs<10,"0"&Secs,Secs)

 

I hope I answered your question!

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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