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
aho
New Member

Calculate percentage of duration


Hi everybody, I have a production machine that produces goods, and for each item produced, a row is sent to CosmosDB, which I'm using as a data source in PowerBI. Some samples of these rows are as follows (simplified)

 

MachineIDDateTimeDuration
S101.03.202009:0000:15
S101.03.202012:1001:20
S202.03.202020:0000:45
S204.03.202002:1002:10

 

The machines are operated by staff in shifts. Some days the shifts are the same, but shorter shifts on fridays for example. (But at a regular defined interval)

 

ShiftnameStartStopShift duration (minutes)Weekday (numeric)
Shift106:0018:007201,2,3,4
Shift218:0002:004801,2,3,4
Shift306:0015:005405
Shift415:0021:003605

 


Now I want to calculate how efficient one shift on a specific day is. If the sum of the duration for a specific shift on a particular day is half of the duration of the shift, the calculated value should be 50%.
 
I assuming I have to make a new table where I enters the shift periods, and make a new column in the "machine data" that picks up which shift each row belongs to.
 
I hope someone can point me in the right direction for:
- How to lookup shift from another table based on the timestamp.
- How and in what part of PowerBI I can sum the duration of all the rows for a particular shift.
 

2 REPLIES 2
v-yuaj-msft
Community Support
Community Support

Hi @aho ,

 

Could you please share the expected result to have a clear understanding of your question? I can do some tests for you.

You can attach your screenshot or save your files in some cloud sharing platforms and share the link here. 

How to provide sample data in the Power BI Forum - Microsoft Power BI Community

 

Best Regards,

Yuna

lbendlin
Super User
Super User

You can use calculated columns or measures in Power BI to implement your logic.  Make sure to think about how you want to cover cases where the production process stretches across shifts. Have you decided on a data model yet?

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.