Forum Discussion

andbeh's avatar
andbeh
New Member
2 years ago
Solved

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 ...
  • Anonymous's avatar
    Anonymous
    2 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 Kong

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.