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

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.

Reply
vrocca
Advocate IV
Advocate IV

How to show/hide points on a map based on slicer

Hi all - I'm trying to create a Map chart, using a field with Lat,Long coordinates to plot my values, and I only want to show the points when the data is filtered to a State. Is there a DAX formula that can help me achieve this?

 

My data in the table looks like this:

 

State | Location

FL          29.7,-85.02

FL          30.4,-83.4

TX         30.05,-94.75

TX         32.70,-99.3

 

I have a State slicer on the dashboard. If no state has been selected, I don't want the map to show any points (or maybe default it to somewhere in the center of the U.S.). Once a State has been selected on the slicer, then the map would display the Locations within that state.

 

Thanks in advance!

Thanks,
Victor Rocca | www.victorrocca.com
2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

Perhaps a little tricky. Create a measure IsFiltered like:

 

IsFiltered = ISFILTERED(Cities[State]) * 1.

Change the type of the measure to Whole Number.

 

Add "IsFiltered" to your Visual Level Filters. 

 

Set it to only display when IsFiltered = 1.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Hi vrocca,

 

 

I checked the page you shared, but the page showing me a Message not found information. Would it be available for you to share the filter configuration with a screenshot in your next post?

 

If the Map Chart already has one filter applied, then we may consider change the measure with the formula below:

ISfiltered = IF(

                    ISFILTERED(Table[State]),

                        IF(HASONEFILTER(Table1[State]),

                             0,

                             1),

                    0)

Then, add the ISfiltered to Map Chart Visual level filter, and apply filter when the value is set to 1. See if this would make the slicer work.

And if any further help needed, please feel free to post back.

Regards

View solution in original post

6 REPLIES 6
jayeckles
Advocate III
Advocate III

If the data from the slicer and the map are coming from the same table, it's in the bag.

 

If not, you need a cross-filtered relationships between the slicer table and the table the map data comes from.  If you remind me on Monday, I'll pull out the dashboard where I've done exactly this and see if I can give you more details.

Greg_Deckler
Super User
Super User

Perhaps a little tricky. Create a measure IsFiltered like:

 

IsFiltered = ISFILTERED(Cities[State]) * 1.

Change the type of the measure to Whole Number.

 

Add "IsFiltered" to your Visual Level Filters. 

 

Set it to only display when IsFiltered = 1.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Ok, I see what's going on in my dashboard now. I have a  Report Level filter on the States to exclude states for which I have no data for. So when I use the ISFILTERED() function, it always returns true regardless of what I select on the slicer in the dashboard. Any thoughts on how to get around this? 

 

BTW you can access the dashboard here: http://community.powerbi.com/t5/Data-Stories-Gallery/U-S-Weather-Analysis/m-p/55879

 

 

Thanks,
Victor Rocca | www.victorrocca.com

Hi vrocca,

 

 

I checked the page you shared, but the page showing me a Message not found information. Would it be available for you to share the filter configuration with a screenshot in your next post?

 

If the Map Chart already has one filter applied, then we may consider change the measure with the formula below:

ISfiltered = IF(

                    ISFILTERED(Table[State]),

                        IF(HASONEFILTER(Table1[State]),

                             0,

                             1),

                    0)

Then, add the ISfiltered to Map Chart Visual level filter, and apply filter when the value is set to 1. See if this would make the slicer work.

And if any further help needed, please feel free to post back.

Regards

Thanks! I ended up applying the report filters in the data query, and then using the ISFILTERED() function. I had to bring in a measure from the main table so that when ISFILTERED() returned 1, it would only show stations with data associated with them. Here's the end result if you are interested: https://app.powerbi.com/reports/7261ca37-fd37-4a58-942b-5c62fd26964e

Thanks,
Victor Rocca | www.victorrocca.com
DivyaP
Frequent Visitor

Hi Victor,

am not able to access your dashboard.

I am trying to get the value selected in a slicer. Ex: table displaying Year along with the other values where as slicer is on the Year column of the same table.

I created a measure as test =ISFILTERED(DateTime[FiscalYear])

This is always giving false irrespective of whether i filter the table using slicer or not.

 

Note: am using direct excel as the source and not done any modification to the data at query level or report level.

 

Thanks in advance

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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