March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
133 | |
91 | |
88 | |
64 | |
58 |
User | Count |
---|---|
201 | |
137 | |
107 | |
73 | |
68 |