Forum Discussion
Summing one column by another
Hi,
I am trying to create a pie chart showing the amount of down time each production line has had in our factory in a given time period. Each line has a number of machines in it and the downtime is recorded for each machine individually therefore I want to sum the down time for the whole production line for the period of time chosen.
in Excel this would look like:
I have tried to roll-up the machine numbers but that hasn't worked and I'm still either getting the individual down time per machine OR I'm getting the sum of all down time for the whole period on all machines.
Is there a way to sum the down time by production line and show it in a pie chart? Or if not a pie chart, another visual?
- Anonymous5 years ago
Hi Anonymous,
Yes, it is possible.
You can add a calculated column not your table to extract the left part of 'Asset Number', then you can use it on the pie chart and change the category field and these values will be auto aggregated.Regards,
Xiaoxin Sheng
8 Replies
- negi007
Community Champion
Anonymous I understand your downtime in hours, so in powerbi you may need to convert hours which is in time format to actual minutes or hours to arrive at sum of downtime by machin
Time (in hours) = (HOUR('Machin downtime'[Down Time])*60+MINUTE('Machin downtime'[Down Time]))/60below is the output you are expecting
- AnonymousNot applicable
Hi Anonymous,
Did this 'prod- mach' field really exist in your table? If not, you can create a calculated column to contact these field values and use it in the pie as category and value with value field with summary mode 'sum'.
Rgards,Xiaoxin Sheng
- AnonymousNot applicable
AnonymousYes, I tried that, but rather than a calculated column I used a measure as I needed to remove the last few digits of the asset number. However when I try to put the measure into the 'Legend' field it won't accept it. Can you add measures to the Legend field?
- AnonymousNot applicable
Anonymous Using a column has allowed me to put the asset number into the 'Legend' column, so thank you for suggesting that. However my problem is that it's now summing all my Down Time for all machines into a single number on my pie chart.
Perhaps I have used the wrong DAX to create my column? Here's what I did. This DAX was meant to roll up the machine numbers to the production line level (by removing the last 4 digits), so I could see the down time for each production line:
Asset No(3) = Switch( true(),
CONTAINSSTRING(MIN('wkaw'[assetno]),"ASSY"), LEFT(MIN('wkaw'[assetno]), 11),
CONTAINSSTRING(MIN('wkaw'[assetno]),"PRINT"), LEFT(MIN('wkaw'[assetno]), 12))This is what I'm seeing:
- AnonymousNot applicable
Hi Anonymous,
Can please share some dummy data with a similar data structure and expected results? It should help us clarify your scenario and test to coding formula.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng