Forum Discussion
andbeh
2 years agoNew Member
Calculate Contribution margin using Sales and Purchase tables
Hello, I'm trying to calculate the Contribution margin by taking the sales data from one table and the purchasing data from another. The Sales table contains the following columns: - OrderID ...
- Anonymous2 years ago
Hi andbeh ,
Based on your description, I created the following data model. Please refer to the following dax formula.
Result = CALCULATE ( MAX ( Sales[SalesPrice] ), FILTER ( ALL ( Sales ), Sales[ProductID] = MAX ( 'Product'[ProductID] ) && Sales[DateID] = MAX ( Sales[DateID] ) ) ) - CALCULATE ( MAX ( Purchasing[PurchasePrice] ), FILTER ( ALL ( Purchasing ), Purchasing[DateID] = MAX ( Purchasing[DateID] ) && Purchasing[ProductID] = MAX ( Purchasing[ProductID] ) ) )Best Regards,
Adamk KongIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
2 years agoNot applicable
Hi andbeh ,
Based on your description, I created the following data model. Please refer to the following dax formula.
Result =
CALCULATE (
MAX ( Sales[SalesPrice] ),
FILTER (
ALL ( Sales ),
Sales[ProductID] = MAX ( 'Product'[ProductID] )
&& Sales[DateID] = MAX ( Sales[DateID] )
)
)
- CALCULATE (
MAX ( Purchasing[PurchasePrice] ),
FILTER (
ALL ( Purchasing ),
Purchasing[DateID] = MAX ( Purchasing[DateID] )
&& Purchasing[ProductID] = MAX ( Purchasing[ProductID] )
)
)
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.