Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
mahendrapal1792
Regular Visitor

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 2'[Quantity])  and I got value  61,650,562.50 and when I created a calculated column using dax function which is  Total Profit 2 = (('Orders 2'[Selling Price])-('Orders 2'[Product Cost]))* ('Orders 2'[Quantity])   and I got value 594,927.50 through table is same and values are also same 

I am sharing that table here please help me  

mahendrapal1792_1-1703154160201.png

 

mahendrapal1792_2-1703154450128.png

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  

 

 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

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])

vyiruanmsft_0-1703487048190.png

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]) 

vyiruanmsft_1-1703487173425.png

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

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

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

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])

vyiruanmsft_0-1703487048190.png

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]) 

vyiruanmsft_1-1703487173425.png

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ryan_mayu
Super User
Super User

@mahendrapal1792 

pls change the measure to 

total profict = sumx('Table',('Table'[selling price]-'Table'[product cost])*'Table'[quantity])

11.PNG

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.