The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have a simple table consists of product price and quantity for each customer. I wanted to calculated total sales amount for each customer in two different ways just to explore the difference between calculated column and measure. Essentially, i would like to understand how and why the measure, SUM(QUANTITY) * SUM(PRICE) is 275 for Jack? ideally, it should be 135.
Thanks,
Nawaz
Solved! Go to Solution.
Hi @Nawaz We can do the calcualtion for total sales amount for each customer
The measure SUM('Table'[Quantity]) * SUM('Table'[Price]) is incorrect because it sums the quantities and prices separately and then again multiplies these totals. This approach does not respect the row context thats why you are getting 275 abnormal value.
calculated column to calculate Total sales:
Using measure: Total sales sum:
With one single measure using sumx(iteration functions) you can create Total sales measure as follows:
In report view:
Hope my explaination is clear. Thank you
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
@rajendraongole1 thanks for the explaination.
I have a follow up question, when i did DISTINCTCOUNT(CUSTOMER), the measure returned 2 rows which is correct. Whereas, DISTINCTCOUNT(CUSTOMER) in the calculated column returns 8 rows for above dataset.
Can you please let me now whats the reason for such behaviour for same logic.
Thanks,
Nawaz
Hi @Nawaz - Measures are dynamic and calculated based on the context of the current filter or row in a report or visualization.it will return 2 because there are two unique customers (Jack and Pam). where as
In calculated columns are computed for each row in the table at the time of data refresh, and they do not change dynamically based on filters in reports. When you add a calculated column using DISTINCTCOUNT(CUSTOMER), it is essentially calculating the distinct count for each row independently, which does not make logical sense in this context.
However, since calculated columns are evaluated row by row calculations.
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
Hi @Nawaz We can do the calcualtion for total sales amount for each customer
The measure SUM('Table'[Quantity]) * SUM('Table'[Price]) is incorrect because it sums the quantities and prices separately and then again multiplies these totals. This approach does not respect the row context thats why you are getting 275 abnormal value.
calculated column to calculate Total sales:
Using measure: Total sales sum:
With one single measure using sumx(iteration functions) you can create Total sales measure as follows:
In report view:
Hope my explaination is clear. Thank you
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
User | Count |
---|---|
74 | |
70 | |
39 | |
30 | |
28 |
User | Count |
---|---|
104 | |
95 | |
51 | |
48 | |
46 |