Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
JimboJamesR
New Member

Shape Map - zoom to state of selected county

Hi there,

 

I have a dataset of vales by county and state in the US.

 

When a value is selected in a county-level Slicer, I'd like the (state/county-level) Shape Map to zoom to the relevant state. For example, when selecting Clark County, the map zooms to Nevada, with Clark County highlighted in a color of my choosing. With no value selected, it is simply a map of the US.

 

Do I need a measure that is then used as a filter on the map and, if so, how would I calculate it? Any help greatly appreciated.

3 REPLIES 3
rajendraongole1
Super User
Super User

Hi @JimboJamesR  - you'll need to create a measure that dynamically filters the state based on the selected county.

 

Create a Measure to Filter the State

 

SelectedState =
VAR SelectedCounty = SELECTEDVALUE(YourTable[County])
RETURN
CALCULATE(
MAX(YourTable[State]),
YourTable[County] = SelectedCounty
)

When no county is selected, the Shape Map shows the full USA.When a county is selected, the map zooms into the respective state and highlights the county.

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi @rajendraongole1 ,

Thanks for your reply.

 

I've created the above measure "SelectedState". Added to a Card, It returns NV when selecting Clark County from the County Slicer, as expected.

 

I've turned off filtering on the county-state-level Shape Map for that Slicer, as doing so zooms in at the county level.

When I add the Measure to the Filters pane, I get the option to filter by 'is', 'is not blank', 'is not empty' etc etc. None of these options allow me to zoom in on the map. Can you please advise me what I need to do to get the Shape Map using this measure as a Filter?

Thanks again

Hi @JimboJamesR  - Create a Calculated Table for State Filtering

StatesTable = DISTINCT('YourCountyTable'[State])

 

This creates a list of unique states.

 

Create a Measure to Match Selected State

FilteredState =
IF(
MAX(StatesTable[State]) = [SelectedState], 1, 0
)

 

This compares each state with the selected state from the slicer.

Select the Shape Map visual.
In the Filters pane, drag FilteredState to "Visual Filters."
Set it to show only values where FilteredState = 1.

 

Hope it works.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.