Forum Discussion

fibaek's avatar
fibaek
Helper I
5 years ago
Solved

Using Filter with Dynamic Axis

Hi I have used Guy In a Cube's guide to build a dynamic axis on a visual. However, I am unable to apply a filter to that visual. Example: I have a geographical hierarchy with region and country.  ...
  • v-zhenbw-msft's avatar
    5 years ago

    Hi fibaek ,

     

    We can add a new region table and change your measure to meet your requirement.

     

    1. Create a region table that has no relationship.

     

    Region table = VALUES('Table'[Region])

     

     

     

    2. We can create a measure like this,

     

    Measure = 
    var _selectregion = SELECTEDVALUE('Region table'[Region])
    return
    if(
        HASONEVALUE('Union Table'[Type]), 
                SWITCH(
                    VALUES('Union Table'[Type])
                    ,"Country",
                    IF(
                        _selectregion="",
                        CALCULATE(SUM('Table'[Value])
                                        ,TREATAS(VALUES('Union Table'[Country])
                                                ,'Table'[Country])),
                                                CALCULATE(SUM('Table'[Value]),TREATAS(VALUES('Union Table'[Country])
                                                ,'Table'[Country]),'Table'[Region]=_selectregion))
                    ,"Region",CALCULATE(SUM('Table'[Value])
                                        ,TREATAS(VALUES('Union Table'[Country])
                                                ,'Table'[Region]))
                )
    )
    

     

     

     

    3. If you are not familiar with the previous operation, please refer to this blog.

    https://www.kasperonbi.com/dynamically-switching-axis-on-visuals-with-power-bi/

     

    If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

     

    Best regards,

     

    Community Support Team _ zhenbw

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    BTW, pbix as attached.