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.
Does anyone know how to detect/get the current hierarchy level from “Axis” on a column chart?
For example, say I have a 4 column table with 10 records:
Column [National] with value of “All”
Column [State] with values “CO”, “TX” and “AZ”
Column [City] with 3 cities in CO, 3 cities in TX and 4 cities in AZ
Column [Count] with a numeric value, e.g. city population size
On the column chart, I set “Axis” as follows:
National
State
City
And I set “Value” as measure [Test], where [Test] is like this (pseudocode):
[Test] = if [current value of Axis] = “National” then [Measure A] else if [current value of Axis] = ”State” then [Measure B] else [Measure C]
...where Measures A, B and C are all different aggregations of [Count] using different modifications to filter context with CALCULATE.
Is there programmatic to detect with a DAX command the action of drill down from one level of the Axis hierarchy to another?
Solved! Go to Solution.
Makes sense. Thank you very much for your help Qiuyun Yu.
Hi @gconnolljr,
You can create a measure use IsFiltered() function and put it as the chart value (In your scenario, you can replace 1 as Measure A, 2 as Measure B, 3 as Measure C):
Measure = IF(ISFILTERED('Table2'[National]),1,IF(ISFILTERED(Table2[State]),2,IF(ISFILTERED(Table2[City]),3,BLANK())))
That's pretty slick...thank you!
I can see it working when I choose to "Go to next level in the hiearchy", but not if I try to "Expand to next level in the hiearchy". Got any magic for that, too?
Hi @gconnolljr,
If current level is National, use "Expand to next level in the hierarchy" action will have National and State both be filtered, so the previous measure doesn't work. You can create a measure below:
ExpandNextLevel = IF(ISFILTERED(Table1[National]) && ISFILTERED(Table1[State]) && ISFILTERED(Table1[City]),3,IF(ISFILTERED(Table1[National]) && ISFILTERED(Table1[State]),2,IF(ISFILTERED(Table1[National]),1,BLANK())))
Please note this measure will not work when use "Go to next level in the hierarchy". We can't catch the current level use one measure for both "Go to next level in the hierarchy" and "Expand to next level in the hierarchy".
Best Regards,
Qiuyun Yu
Makes sense. Thank you very much for your help Qiuyun Yu.
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 |
---|---|
110 | |
98 | |
78 | |
64 | |
55 |
User | Count |
---|---|
143 | |
109 | |
89 | |
84 | |
66 |