Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hey guys,
I have 3 simplified data tables as follows (the third is a calendar table):
"Umsätze Produkt"
"Warengruppen"
First I wanted to calculate the deviation of the product prices (latest price last year compared with the max prices per month from this year).
This results in the table as follows with the help of you guys in another thread:
The Deviation is calculated by following code:
Deviation =
VAR CurrentPrice =
CALCULATE (
MAX ( 'Umsätze Produkt'[Preis] ),
'Umsätze Produkt'[Jahr] = YEAR ( TODAY () )
)
VAR LatestPrice =
CALCULATE (
LASTNONBLANKVALUE ( 'Umsätze Produkt'[Datum], SUM ( 'Umsätze Produkt'[Preis] ) ),
PREVIOUSYEAR ( Kalender[Datum] )
)
RETURN
IF (
DIVIDE ( CurrentPrice, LatestPrice ) - 1 = -1.00,
BLANK (),
DIVIDE ( CurrentPrice, LatestPrice ) - 1
)
The final result I need is the average deviation per category broken down per month:
As you can see, it's empty and I really don't know how to calculate the average of a measure...
Could you guys help me out?
Thx and greets
Solved! Go to Solution.
Thanks for the file. I rewrote the measure to include additional columns in the virtual table (in case they aren't in the visual):
Deviation Average =
VAR vTable =
ADDCOLUMNS (
SUMMARIZE (
'Umsätze Produkt',
Kalender[Year],
Kalender[Month],
'Umsätze Produkt'[Product],
Warengruppen[Category]
),
"@Amount", [Deviation]
)
RETURN
AVERAGEX ( vTable, [@Amount] )
Is this correct? If not, can you provide a screenshot of the expected result?
Proud to be a Super User!
You could try a measure like this:
Deviation Average =
VAR vTable =
ADDCOLUMNS ( VALUES ( Warengruppen[Category] ), "@Amount", [Deviation] )
VAR vResult =
AVERAGEX ( vTable, [@Amount] )
RETURN
vResult
Proud to be a Super User!
Hi DataInsight and thank you for your reply,
I tried this measure and get this result:
When I put in the upper table it shows the exact same values but it doesn't aggregate in the table below. Is there something wrong with my implementation?
Greets
I would need to see your pbix. Can you share a sanitized version via one of the file services like OneDrive?
Proud to be a Super User!
I uploaded the file here.
I found several errors.
How can we exclude the -100% and visualize the Average Deviations per months correctly?
Thank you for your help. Much appreciated.
Thanks for the file. I rewrote the measure to include additional columns in the virtual table (in case they aren't in the visual):
Deviation Average =
VAR vTable =
ADDCOLUMNS (
SUMMARIZE (
'Umsätze Produkt',
Kalender[Year],
Kalender[Month],
'Umsätze Produkt'[Product],
Warengruppen[Category]
),
"@Amount", [Deviation]
)
RETURN
AVERAGEX ( vTable, [@Amount] )
Is this correct? If not, can you provide a screenshot of the expected result?
Proud to be a Super User!
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
111 | |
96 | |
90 | |
79 | |
67 |
User | Count |
---|---|
153 | |
125 | |
114 | |
111 | |
95 |