Forum Discussion
ModelFear
2 years agoFrequent Visitor
Need help with DAX formula
Dear community, I post this question as a fresh question if it is ok. Below is my Sales table of various dishes : Below is my table called Recipe, where Subtotal is the cost to...
- 2 years ago
Note LOOKUPVALUE wouldn't work here either because there are multiple records per [Dish ID] in the Recipe table, so some form of aggregation is required. I've opted to sum 'Recipe'[Cost] but you could also use:
Margin =
VAR RecipeCost = Calculate(Max('Recipe'[Subtotal]),
'Recipe'[Dish ID]=EARLIER('Sales'[Dish ID]))
RETURN
'Sales'[Selling Price per kg] - RecipeCost
Also note calculations like this as well as the Subtotal field in 'Recipe' would be good candidates for creating measures rather than calculated columns.
manvishah17
2 years agoSolution Supplier
Hi ModelFear ,
RELATED Dax can be use when there is direct relation btw two tables.
Refer this for more information.