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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mtrevisiol
Helper IV
Helper IV

Calculate total minutes (one value for each day)

Hi everyone, I've got this table:

mtrevisiol_0-1634133968924.png

 

For each day, I've got the list of operators who worked in each WC (Work Center), their start time anda end time. The column Available minutes is equal to 225 if the date is a Saturday, 450 otherwise. The column Elapsed minutes is given by Datetime End - Datetime Start.

 

My purpose is to get for each Day, for each WC the available minutes of that day and the total elapsed minutes. The problem is that I would like to have 450 as available minutes of the day, not the sum for each Operator, and the total sum of the Elapsed minutes.

 

This is the ideal result (referred to the whole table) obtained through a pivoting with Excel:

mtrevisiol_1-1634135707474.png

 

Here is the xlsx file: https://www.dropbox.com/scl/fi/ujxx5dvq7auw48xqjr0u5/Cartel.xlsx?dl=0&rlkey=ozoej78y0zlj22198t8lsdgl...

 

Thank you!

 

1 ACCEPTED SOLUTION
ChrisMendoza
Resident Rockstar
Resident Rockstar

@mtrevisiol -

I attempted a solution. Using this as the sample data:

image.png

Result:

image.png

Basically I used Power Query to:

  • Calculate the Duration.TotalMinutes([Datetime stop]-[Datetime start])
  • Grouped by [WC] and [Day]
    • SUM of the above calculation
  • Added [isSaturday] if Date.DayOfWeek([Day],Day.Monday) = 5 then true else false
  • Added your 'minutes available' logic each if [isSaturday] = true then 225 - [Total Minutes Elapsed] else 450 - [Total Minutes Elapsed]
  • Removed columns





Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

2 REPLIES 2
ChrisMendoza
Resident Rockstar
Resident Rockstar

@mtrevisiol -

I attempted a solution. Using this as the sample data:

image.png

Result:

image.png

Basically I used Power Query to:

  • Calculate the Duration.TotalMinutes([Datetime stop]-[Datetime start])
  • Grouped by [WC] and [Day]
    • SUM of the above calculation
  • Added [isSaturday] if Date.DayOfWeek([Day],Day.Monday) = 5 then true else false
  • Added your 'minutes available' logic each if [isSaturday] = true then 225 - [Total Minutes Elapsed] else 450 - [Total Minutes Elapsed]
  • Removed columns





Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Thank you so much for the help @ChrisMendoza 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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