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.
I have a dataset with a hierarchy and value, something like this:
Level 1 | Level 2 | Level 3 | Value |
a | category 1 | class 1 | 300 |
a | category 1 | class 2 | 200 |
a | category 2 | class 1 | 500 |
I need to know how I could see the % respected each level inside a Descomposition Tree or Matrix to display it in the same column.
For example if I select only level 1 and level 3 I have to display 80% for class 1, but if I select the levels 1 and 2 I have to see 50% in category 1.
How I could get it?
Solved! Go to Solution.
Hi,
You can use ISINSCOPE function to calculate it:
Measure =
VAR A =
CALCULATE ( SUM ( 'Table'[Value] ), ALL ( 'Table' ) )
RETURN
IF (
ISINSCOPE ( 'Table'[Level 2] ),
IF (
ISINSCOPE ( 'Table'[Level 3] ),
SUM ( 'Table'[Value] ) / A,
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( 'Table', 'Table'[Level 2] IN DISTINCT ( 'Table'[Level 2] ) )
) / A
),
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( 'Table', 'Table'[Level 1] IN DISTINCT ( 'Table'[Level 1] ) )
) / A
)
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
Hi,
You can use ISINSCOPE function to calculate it:
Measure =
VAR A =
CALCULATE ( SUM ( 'Table'[Value] ), ALL ( 'Table' ) )
RETURN
IF (
ISINSCOPE ( 'Table'[Level 2] ),
IF (
ISINSCOPE ( 'Table'[Level 3] ),
SUM ( 'Table'[Value] ) / A,
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( 'Table', 'Table'[Level 2] IN DISTINCT ( 'Table'[Level 2] ) )
) / A
),
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( 'Table', 'Table'[Level 1] IN DISTINCT ( 'Table'[Level 1] ) )
) / A
)
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
@Pedro_R , refer if this can help
https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/
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 |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |