Forum Discussion

mahendrapal1792's avatar
mahendrapal1792
Regular Visitor
2 years ago
Solved

Total Profit DAX function

Hello Community,   I need help understanding these two functions first I have created a measure that is   Total profit = (SUM('Orders 2'[Selling Price])-SUM('Orders 2'[Product Cost]))* SUM('Orders...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi mahendrapal1792 ,

    I made a simplified pbix file(see the attachment) to describe the difference between your first function and second function. Your first function is a measure, which is a dynamic calculation that changes based on the filter context of your report. Your measure calculates the total profit by subtracting the product cost from the selling price and multiplying it by the quantity for each row in the Orders 2 table. Your measure is evaluated at query time, which means it will update whenever you change your filters or slicers in your report.

    Total profit = (SUM('Orders 2'[Selling Price])-SUM('Orders 2'[Product Cost]))* SUM('Orders 2'[Quantity])

    Your second function is a calculated column, which is a static value that is added to an existing table in your data model. Your calculated column calculates the total profit by using the same formula as your measure, but it does not depend on any filter context. Your calculated column is evaluated during data loading, which means it will only calculate once when you load or refresh your data.

     Total Profit 2 = (('Orders 2'[Selling Price])-('Orders 2'[Product Cost]))* ('Orders 2'[Quantity]) 

    The reason why you got different values for your two functions is because they are using different contexts. Your measure uses the current context of your report, which may include filters or slicers that affect your data. Your calculated column uses the original context of your table, which does not include any filters or slicers.

    Calculated Columns and Measures in DAX

    Calculated Columns vs Measures

    Best Regards