Forum Discussion
Sum quantity per partcode
Hello,
I'm struggling with the sum of quantities per partnumber. Our machines have framenumbers and those machines are build with parts. I would like to sum the parts in an overview.
This is the data:
| Framenumber | PartNumber | Quantity |
| 01504M | 112455 | 2 |
| 01504M | 238574 | 22 |
| 01504M | 598749 | 5 |
| 01504M | 254875 | 4 |
| 01504M | 254152 | 11 |
| 01504M | 658745 | 23 |
| 01504M | 158965 | 1 |
| 01504M | 128544 | 45 |
| 01504M | 123659 | 7 |
| 01504M | 128588 | 9 |
| 01504M | 124588 | 2 |
| 01605D | 112455 | 2 |
| 01605D | 238574 | 22 |
| 01605D | 598749 | 5 |
| 01605D | 254875 | 4 |
| 01605D | 254152 | 11 |
| 01605D | 658745 | 23 |
| 01605D | 158965 | 1 |
| 01605D | 128544 | 45 |
| 01605D | 123659 | 7 |
| 01605D | 128588 | 9 |
| 01605D | 124588 | 2 |
| 07822E | 112455 | 2 |
| 07822E | 238574 | 22 |
| 07822E | 598749 | 5 |
| 07822E | 254875 | 4 |
| 07822E | 254152 | 11 |
| 07822E | 658745 | 23 |
| 07822E | 158965 | 1 |
| 07822E | 128544 | 45 |
| 07822E | 123659 | 7 |
| 07822E | 128588 | 9 |
| 07822E | 124588 | 2 |
And the result should look like this:
| PartNumber | Quantity |
| 112455 | 6 |
| 238574 | 66 |
| 598749 | 15 |
| 254875 | 12 |
| 254152 | 33 |
| 658745 | 69 |
| 158965 | 3 |
| 128544 | 135 |
| 123659 | 21 |
| 128588 | 27 |
| 124588 | 6 |
| 112455 | 6 |
| 238574 | 66 |
| 598749 | 15 |
| 254875 | 12 |
| 254152 | 33 |
| 658745 | 69 |
| 158965 | 3 |
| 128544 | 135 |
| 123659 | 21 |
| 128588 | 27 |
| 124588 | 6 |
I tried this but it seems that the total QTY is summed and multiplied by three:
oh okay WLFRD , then try this:-
Column = CALCULATE ( SUM ( 'ProductionPartAll'[Quantity] ), FILTER ( 'ProductionPartAll', 'ProductionPartAll'[PartNumber] = EARLIER ( 'ProductionPartAll'[PartNumber] ) ) )
7 Replies
- vanessafvgCommunity Champion
what result are you getting? can you share?
I get this result from your measure
- WLFRDHelper III
This is my result in Power BI:
PartNumber Total_QTY_Per_PartNumber 128544 405 658745 207 238574 198 254152 99 128588 81 123659 63 598749 45 254875 36 112455 18 124588 18 158965 9 - WLFRDHelper III
Is it possible to make the calculation dynamic? I mean, based on how we filter the data, it has to calculate the sum per PartNumber.
- Samarth_18Community Champion
Hi WLFRD ,
You can directly drag your partnumber and Quantity column then mark Quantity column summerization as Sum.
Thanks,
Samarth
- WLFRDHelper III
Thanks! But I would like to have a calculated column. I need this total column for another calculation.
- Samarth_18Community Champion
oh okay WLFRD , then try this:-
Column = CALCULATE ( SUM ( 'ProductionPartAll'[Quantity] ), FILTER ( 'ProductionPartAll', 'ProductionPartAll'[PartNumber] = EARLIER ( 'ProductionPartAll'[PartNumber] ) ) )