Forum Discussion
DAX Group by Calculation
Hello,
Please can someone help me with my calculation.
I have a dataset which looks like the below, I cannot change the structure of the data. I need to create a calculation which will multiply the 'UnitOfMeasure' (Recycled and Reused) against the associated Unit Weight for that 'AssetType'. e.g. Laptops Recycled (1438) * Laptops Unit Weight (2) = 2876
| AssetType | volume | UnitOfMeasure |
| Laptops | 1438 | Recycled |
| Laptops | 16676 | Reused |
| Laptops | 2 | Unit Weight |
| Monitors | 450 | Recycled |
| Monitors | 9571 | Reused |
| Monitors | 8 | Unit Weight |
| Printers | 0 | Recycled |
| Printers | 11 | Reused |
| Printers | 20 | Unit Weight |
| Server | 25 | Recycled |
| Server | 26 | Reused |
| Server | 12 | Unit Weight |
I need to calculate the total for Recycled and Reused, in the example provided I should be returned with the total below of 6,776 Recycled and 110,320 Reused.
| AssetType | Recycled | Reused |
| Laptops | 2,876 | 33,352 |
| Monitors | 3,600 | 76,568 |
| Printers | 0 | 88 |
| Server | 300 | 312 |
| Total | 6,776 | 110,320 |
Hi Anonymous
Try this 2 formulas:1.
recycled =sumx(SUMMARIZE('Table','Table'[AssetType],"total rec",CALCULATE(sum('Table'[volume]),'Table'[UnitOfMeasure]="Recycled")*CALCULATE(sum('Table'[volume]),'Table'[UnitOfMeasure]="Unit Weight")),[total rec])2.reused =sumx(SUMMARIZE('Table','Table'[AssetType],"total reu",CALCULATE(sum('Table'[volume]),'Table'[UnitOfMeasure]="Reused")*CALCULATE(sum('Table'[volume]),'Table'[UnitOfMeasure]="Unit Weight")),[total reu])the pbix is attached
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
2 Replies
- Ritaf1983Super User
Hi Anonymous
Try this 2 formulas:1.
recycled =sumx(SUMMARIZE('Table','Table'[AssetType],"total rec",CALCULATE(sum('Table'[volume]),'Table'[UnitOfMeasure]="Recycled")*CALCULATE(sum('Table'[volume]),'Table'[UnitOfMeasure]="Unit Weight")),[total rec])2.reused =sumx(SUMMARIZE('Table','Table'[AssetType],"total reu",CALCULATE(sum('Table'[volume]),'Table'[UnitOfMeasure]="Reused")*CALCULATE(sum('Table'[volume]),'Table'[UnitOfMeasure]="Unit Weight")),[total reu])the pbix is attached
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly - AnonymousNot applicable
It works, thank you for your help! 🙂