Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I have a matrix with 4 levels, the fist level comes from a column of the date dim and the remainig 3 levels are from the produt dimension, i also have a measure called und sale wich is the sum of the sale units
What i want is to take the average, tha is, for my hormonal group the units of all the available months are added and divided by two (the average) then the same for the anti-pain group and so on for the others groups and the same for the others levels of hierarchy
I have usued these dax:
Hi @Yeimy ,
I created some data:
Are you referring to the different levels of Row subtotals showing the average for that level.
Measure follows the context of the "Total" row and is calculated in that context. Therefore, using a measure in a column of a table visualization may have unexpected values in the "Total" column.
You can consider using the switch() + Isinscope() function to determine the corresponding level in the matrix, and use the corresponding rule based on the corresponding level
SWITCH function (DAX) - DAX | Microsoft Learn
ISINSCOPE function (DAX) - DAX | Microsoft Learn
Here are the steps you can follow:
1. Create measure.
Measure =
SWITCH(
TRUE(),
ISINSCOPE('Table'[Group4]),1,
ISINSCOPE('Table'[Group3]),2,
ISINSCOPE('Table'[Group2]),3,
ISINSCOPE('Table'[Group1]),4,0)
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thank you,
But that doesn't solve my problem
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
12 | |
10 | |
6 |