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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
elliotb
Regular Visitor

Filtering a map based on time period from a slicer

Hi All,

 

I have a dataset that contains a column called date. Currently I am plotting this data set on a map based on zip code. I would like to add functionality so that the map only display points where the date falls into the selected range:

 

i.e when the slicer says:

LTD: Shows all points(Launch to Date)

YTD: Shows all points where date is in current year

MTD: Shows all points where data is in current month

Q1: Shows all points where data is between 1/1/2021-4/1/2020 etc.

 

Is there a way to do this easily? I was thinking I could create a measure that is a binary that switches to 1 - 0 depending on what the time period selected in the slicer is but I haven't been able to figure it out. I have already experimented with the Timeline 2.4.0 custom visual and while this works this isn't exactly the functionality I am looking for.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @elliotb ,

 

According to your description, I think you are going to show maps of different periods by filtering LTD, YTD, MTD and Q1.

 

Here's my solution.

Sample data

vstephenmsft_0-1639632981931.png

 

1.Create a seperate table by entering data.

vstephenmsft_1-1639621893680.png

 

2.Create a calendar table.

Date = CALENDAR(MIN('Table (2)'[date]),MAX('Table (2)'[date]))

vstephenmsft_1-1639633022535.png

 

3.Relationships is as follows.

vstephenmsft_2-1639633055449.png

 

4.Create a flag measure. Put it into the map visual and set show items when the value is 1.

flag = 
VAR _DATE =
    MAX ( 'Date'[Date] )
VAR _TODAY =
    TODAY ()
RETURN
    SWITCH (
        SELECTEDVALUE ( 'Table'[Period] ),
        "LTD", 1,
        "YTD", IF ( YEAR ( _DATE ) = YEAR ( _TODAY ), 1 ),
        "MTD",
            IF ( YEAR ( _DATE ) = YEAR ( _TODAY ) && MONTH ( _DATE ) = MONTH ( _TODAY ), 1 ),
        "Q1",
            IF ( _DATE >= DATE ( 2020, 4, 1 ) && _DATE <= DATE ( 2021, 1, 1 ), 1 )
    )

vstephenmsft_3-1639633169075.png

 

5.Now you can filter by the slicer.

vstephenmsft_4-1639633198442.png

vstephenmsft_5-1639633205323.png

 

 

Best Regards,

Stephen Tao

 

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

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @elliotb ,

 

According to your description, I think you are going to show maps of different periods by filtering LTD, YTD, MTD and Q1.

 

Here's my solution.

Sample data

vstephenmsft_0-1639632981931.png

 

1.Create a seperate table by entering data.

vstephenmsft_1-1639621893680.png

 

2.Create a calendar table.

Date = CALENDAR(MIN('Table (2)'[date]),MAX('Table (2)'[date]))

vstephenmsft_1-1639633022535.png

 

3.Relationships is as follows.

vstephenmsft_2-1639633055449.png

 

4.Create a flag measure. Put it into the map visual and set show items when the value is 1.

flag = 
VAR _DATE =
    MAX ( 'Date'[Date] )
VAR _TODAY =
    TODAY ()
RETURN
    SWITCH (
        SELECTEDVALUE ( 'Table'[Period] ),
        "LTD", 1,
        "YTD", IF ( YEAR ( _DATE ) = YEAR ( _TODAY ), 1 ),
        "MTD",
            IF ( YEAR ( _DATE ) = YEAR ( _TODAY ) && MONTH ( _DATE ) = MONTH ( _TODAY ), 1 ),
        "Q1",
            IF ( _DATE >= DATE ( 2020, 4, 1 ) && _DATE <= DATE ( 2021, 1, 1 ), 1 )
    )

vstephenmsft_3-1639633169075.png

 

5.Now you can filter by the slicer.

vstephenmsft_4-1639633198442.png

vstephenmsft_5-1639633205323.png

 

 

Best Regards,

Stephen Tao

 

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

 

 

amitchandak
Super User
Super User

@elliotb , with help from a date table 

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))

Qtr Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(ENDOFQUARTER('Date'[Date])))

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))

 

LYTD =

var _max = maxx(allselected('Date', Date[Date])

return

CALCULATE(SUM(Sales[Sales Amount]),filter(all(date),date[date] <=_max ))

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA
Power BI — Qtr on Qtr with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839
https://www.youtube.com/watch?v=8-TlVx7P0A0
Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors