Forum Discussion

jxkang's avatar
jxkang
Frequent Visitor
1 year ago
Solved

Power BI Map Dynamic Level of Location

I would like to create a map visualization that changes the level based on "Country" slicer.

 

If there is only one selection and the selected value is "United States", then the map should show in "State" level.

If there is only one selection and the selected value is NOT "United States", then the map should show in "City" level.

If there are more than one selection in the Country Slicer, then the map should show in "Country" level.


Is this something that is possible?

  • Hi jxkang 

     

    The native visual doesnt support this definitely.

     

    One way to go by would be using bookmark and dax to show any of the 3 visuals based on selected value but I wouldnt recommend this.

     

    You could try using a Field Paramter with 3 fields Country, State and City

     

    Then have a measure to control this selection

    SelectedLevel =

    VAR CountrySelected = SELECTEDVALUE('YourTable'[Country])

    VAR CountCountries = DISTINCTCOUNT('YourTable'[Country])

    RETURN

       IF(

          CountCountries > 1,

          "Country",

          IF(

             CountrySelected = "United States",

             "State",

             "City"

          )

       )

     

    You could probably display a card and use this to change the slicer appropriately based on recommendation.

     

     

    If definitely it needs to be automatic then bookmarks works like this:

     

    3 visuals and manage visibility (i.e visual level filters):

    ShowCountryMap = IF([SelectedLevel] = "Country", 1, 0)

    ShowStateMap = IF([SelectedLevel] = "State", 1, 0)

    ShowCityMap = IF([SelectedLevel] = "City", 1, 0)

     

    Set it to 1 in each of the 3 visuals after creating them

3 Replies

  • Hi jxkang 

     

    The native visual doesnt support this definitely.

     

    One way to go by would be using bookmark and dax to show any of the 3 visuals based on selected value but I wouldnt recommend this.

     

    You could try using a Field Paramter with 3 fields Country, State and City

     

    Then have a measure to control this selection

    SelectedLevel =

    VAR CountrySelected = SELECTEDVALUE('YourTable'[Country])

    VAR CountCountries = DISTINCTCOUNT('YourTable'[Country])

    RETURN

       IF(

          CountCountries > 1,

          "Country",

          IF(

             CountrySelected = "United States",

             "State",

             "City"

          )

       )

     

    You could probably display a card and use this to change the slicer appropriately based on recommendation.

     

     

    If definitely it needs to be automatic then bookmarks works like this:

     

    3 visuals and manage visibility (i.e visual level filters):

    ShowCountryMap = IF([SelectedLevel] = "Country", 1, 0)

    ShowStateMap = IF([SelectedLevel] = "State", 1, 0)

    ShowCityMap = IF([SelectedLevel] = "City", 1, 0)

     

    Set it to 1 in each of the 3 visuals after creating them

  • Hi jxkang 

     

    The native visual doesnt support this definitely.

     

    One way to go by would be using bookmark and dax to show any of the 3 visuals based on selected value but I wouldnt recommend this.

     

    You could try using a Field Paramter with 3 fields Country, State and City

     

    Then have a measure to control this selection

    SelectedLevel =

    VAR CountrySelected = SELECTEDVALUE('YourTable'[Country])

    VAR CountCountries = DISTINCTCOUNT('YourTable'[Country])

    RETURN

       IF(

          CountCountries > 1,

          "Country",

          IF(

             CountrySelected = "United States",

             "State",

             "City"

          )

       )

     

    You could probably display a card and use this to change the slicer appropriately based on recommendation.

     

     

    If definitely it needs to be automatic then bookmarks works like this:

     

    3 visuals and manage visibility (i.e visual level filters):

    ShowCountryMap = IF([SelectedLevel] = "Country", 1, 0)

    ShowStateMap = IF([SelectedLevel] = "State", 1, 0)

    ShowCityMap = IF([SelectedLevel] = "City", 1, 0)

     

    Set it to 1 in each of the 3 visuals after creating them

  • v-kpoloju-msft's avatar
    v-kpoloju-msft
    Icon for Community Support rankCommunity Support

    Hi jxkang,

    Thank you for reaching out to the Microsoft fabric community forum. Also, thanks to MohamedFowzan1, fot his inputs on this thread. I reproduced the scenario, and it worked on my end. I used my sample data and successfully implemented it.



    I am also including .pbix file for your better understanding, please have a look into it:

    Hope this helps clarify things and let me know what you find after giving these steps a try happy to help you investigate this further.

    Thank you for using the Microsoft Community Forum.