Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi guys, I think I have a pretty basic question, but I can't figure it out. Let's say I have the following data:
Product Price
A 12
B 15
C 22
The average of the price is 16.33. I want to add this as a separate column to all the rows like this:
Product Price Average Price
A 12 16.33
B 15 16.33
C 22 16.33
From here on, I would make a new column, called ScaledPrice that would be Price / Average Price like this:
Product Price Average Price Scaled Price
A 12 16.33 0.73
B 15 16.33 0.92
C 22 16.33 1.35
I've been strugling with coming up with the Average Price. Somehow, I keep ending with the same value as the Price in each row. I tried with this:
AveragePrice =
var averageAll = CALCULATE(AVERAGE([Price]); ALLSELECTED('SalesTable'))
return averageAll
When I add this measure by it self (no other fields), it gives me the correct result, but when I drag the product name along with it, the measure is calculated for each row and average of one price is the same value.
Thanks!
Solved! Go to Solution.
@Anonymous
Using this sample table:
With this dax you have the average:
AveragePrice = CALCULATE(AVERAGE('Table'[Price]);ALLSELECTED('Table'))
@Anonymous
Using this sample table:
With this dax you have the average:
AveragePrice = CALCULATE(AVERAGE('Table'[Price]);ALLSELECTED('Table'))
just add new column for average:
AveragePrice= AVERAGE(Table[Price])
and for scaled price:
ScaledPrice = Table[Price]/Table[AveragePrice]
That should be it, if I understood correctly.
Same thing. See the image, I want to have each product's price divided by 37.44 which is the average price of all products here.
Hi @Anonymous,
Please right click your table , then choose “New column” rather than “New measure” as follows and use the following formulas. This way, you will get desired result, for more details, you can review the example in this attached PBIX file.
AveragePrice = AVERAGE(Table1[Price])
ScaledPrice = Table1[Price]/Table1[AveragePrice]
Thanks,
Lydia Zhang
Thanks for your answer Lydia, this is very close to what I want.
But, this does average on the whole table. If I add a filter, the average number stays the same. It needs to be average from what is shown in the table.
Try adding a report level filter with selecting only A and B. So, exclude C and the average remains 16.33.
It needs to be 13.5 now.
Thanks!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
150 | |
115 | |
104 | |
89 | |
65 |