Forum Discussion
Dynamic Names axis based on selected filter.
- 3 years ago
Hey Anonymous,
This is possible by creating a table in which the regions are columns and the rows are countries. And then create a field parameter on it. I used the following sample data:Dim_Countries:
CountryRegionSales
1 A 8 2 A 12 3 A 54 4 B 21 5 B 76 6 B 32 7 B 89 8 B 21 9 C 40 10 C 4 Dim_Region:
RegionA B C Dim_Country_Region (combination table in which you indicate per country to which region it belongs. You could create this table dynamically in M by pivoting the region column in the countries table):
CountryABC
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 Field paramter (refer to the general region column and call it 'All'. And select all the region columns from the combination table underneath):
Parameter = { ("All", NAMEOF('Dim_Region'[Region]), 0), ("A", NAMEOF('Dim_Country_Region'[A]), 1), ("B", NAMEOF('Dim_Country_Region'[B]), 2), ("C", NAMEOF('Dim_Country_Region'[C]), 3) }This is how the models looks:
Use the field parameter as a slicer. And also place the field parameter on the x axis of a visual.
'All' selected:
When you select one region:
Hey Anonymous,
Yeah you are right. I think the easiest way to fix this is to filter the visual, where 'country' is not equal to 'Blank'. You can do this in the filter panel once you've selected the visal.
Hey Barthel ,
The problem with this is that the (Blank) is depended for the region. So in the 'country' field there is no blank, only in the Region fields. But then when I select Americas and is not equal to blank the other regions will only show the total of americas as blank. So I can't take the Blank out of the visual by using the filter panel.
BUT I've found a solution with DAX.....I love DAX
What I did for the blanks is to create a "If(Selectedvalue(" and then for each 'Order' in the parameter a calculation measure where I filter out the blank for that region.
So: IF(SELECTEDVALUE('Parameter'[Parameter order])=1, CALCULATE([Margin], FILTER(Dim_Country_Region,Dim_Country_Region[A]<>BLANK())),
IF(SELECTEDVALUE('Parameter' [Parameter Order])=2, CALCULATE([Margin], FILTER(Dim_Country_Region,Dim_Country_Region[B]<>BLANK())),
IF(SELECTEDVALUE('Parameter' [Parameter Order])=3, CALCULATE([Margin], FILTER(Dim_Country_Region,Dim_Country_Region[C]<>BLANK())),
[Margin]))))
(hope this way, I made the DAX a bit readable/clear)
And that made the blanks disappear!
So thanks for the solution!