'Calculate sum by each category in Power Bi Dax
Solution 1:[1]
Assumign your data looks like this
Table: AllRecipes
Recipe Name | Ingredient Cost Price |
---|---|
112 Apple & Cinnamon Crumble | 0.01 |
112 Apple & Cinnamon Crumble | 0.03 |
112 Apple & Cinnamon Crumble | 0.05 |
112 Apple & Cinnamon Crumble | 0.17 |
112 Apple & Cinnamon Crumble | 0.23 |
113 Banana Pancake | 0 |
113 Banana Pancake | 0 |
113 Banana Pancake | 0.01 |
113 Banana Pancake | 0.18 |
Try the following calculation:
Dax Calculation: Recipe Total Cost Price
Recipe Total Cost Price =
CALCULATE (
SUM ( AllRecipes[Ingredient Cost Price] ),
ALL ( AllRecipes[Ingredient Cost Price] )
)
Output
Solution 2:[2]
Not something like this? Recipe---(1,M)--ProductIngredient(WeightKG)---(M,1)--Ingredient
Per Recipe Cost = CALCULATE(SUMX('ProductIngredient', [IngredientWeight_Kg] *
RELATED('Ingredient'[Price per Kg])
)
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Angelo Canepa |
Solution 2 | Pieter |