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 September 15. Request your voucher.
Hi,
I have a table with 366 rows.
I'm trying to calculate the average in a matrix, but I want the average to be calculated from the level below.
For example, currently the average for “Queens” is calculated using all the 336.
I want to calculate the average for Queens using the 5 fruits’ averages shown below.
The average would be found using ( 99.6323, 99.6334, 99.5594, 99.5856, 99.6368) = 99.6095
Does anyone know how to calculate the average using the numbers from the previous level in a matrix?
Solved! Go to Solution.
I think I got it to work. I calculated the average at each level. Here is an example of the average at the highest level.
_a1 =
Hi @Anonymous
Please try
Average over Fruits =
AVERAGEX(
VALUES(Table[Fruits]),
CALCULATE(AVERAGE(Table[Fruits]))
)
Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your thumbs up!
@ me in replies or I'll lose your thread.
-----------------------------------------------------
Hi @Anonymous
Did you try my formula? I made a small mistake and adjusted it and it should work. Can you please try and show what happens?
Average over Fruits =
AVERAGEX(
VALUES(Table[Fruits]),
CALCULATE(AVERAGE(Table[Data]))
)
Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your thumbs up!
@ me in replies or I'll lose your thread.
-----------------------------------------------------
Hi, @Anonymous
Please try measure formula like:
Average for Queens =
VAR tab =
SUMMARIZE (
'Table',
'Table'[Team],
'Table'[Country],
'Table'[State],
'Table'[County],
'Table'[Fruit],
"Avg", AVERAGE ( 'Table'[Data] )
)
RETURN
AVERAGEX ( tab, [Avg] )
Result =
IF (
ISINSCOPE ( 'Table'[County] ) && NOT ISINSCOPE ( 'Table'[Fruit] ),
[Average for Queens],
AVERAGE ( 'Table'[Data] )
)
Best Regards,
Community Support Team _ Eason
Hi Eason,
Thanks for the ISINSCOPE suggestion and PBIx file. It was helpful.
Your solution does work however my example was too simple. I need to apply the prior level idea to all levels. I tried to create an average table for each level but don't know how to create a nesting formula to use the prior levels' averages. For example, to find the Team average using the Country Average derived from the State Average derived from the County Average.
Any thoughts? I have the latest file of my work but don't see an option to attach the file.
I think I got it to work. I calculated the average at each level. Here is an example of the average at the highest level.
_a1 =
User | Count |
---|---|
70 | |
64 | |
62 | |
49 | |
28 |
User | Count |
---|---|
117 | |
80 | |
65 | |
54 | |
43 |