Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello Community,
I need help understanding these two functions first I have created a measure that is
I am sharing that table here please help me
As you can see here there are two tables under the Orders 2 table and I use the same column to get the total profit
Solved! Go to Solution.
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
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
pls change the measure to
total profict = sumx('Table',('Table'[selling price]-'Table'[product cost])*'Table'[quantity])
pls see the attachment below
Proud to be a Super User!
User | Count |
---|---|
102 | |
90 | |
80 | |
71 | |
70 |
User | Count |
---|---|
114 | |
99 | |
97 | |
73 | |
72 |