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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Veblengood
Helper I
Helper I

Using a filter table to filter dates

Say I have created dates columns with YTD and MTD periods returning TRUE if in period and FALSE else, and want to use a these columns to filter my data with a slicer. The slicer is based on another table called Dimperiods. I came across one solution here, but the problem with this approach is that the Dates table needs to be represented in the visual  for this to work, which is not ideal. Is there a way to work around this? Selecting YTD should filter all the data so inYTD = TRUE.

 

What to Filter? =
VAR __filter = SELECTEDVALUE( Dimperiods[PeriodID] )
VAR __Isfilter =  
    SWITCH(
        __filter,
        "MTD", SELECTEDVALUE( Dates[inMTD] ) = TRUE(),
        "YTD", SELECTEDVALUE( Dates[inYTD] ) = TRUE(),
    )
    RETURN IF( __Isfilter = TRUE(), 1, 0 )
2 REPLIES 2
Anonymous
Not applicable

Hi  @Veblengood ,

I created some data:

vyangliumsft_0-1674110729821.png

Here are the steps you can follow:

1. Create measure.

Flag =
var _select=SELECTEDVALUE('Dimperiods'[PeriodID])
return
SWITCH(
    TRUE(),
_select="MTD"&&MAX('Date'[Date]) >= DATE(YEAR(TODAY()),MONTH(TODAY()),1)&&MAX('Date'[Date])<=TODAY(),1,
_select="YTD"&&MAX('Date'[Date]) >= DATE(YEAR(TODAY()),1,1)&&MAX('Date'[Date])<=TODAY(),1,0)
Measure =
SUMX(ALLSELECTED('Date'),[Value])

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1674110729822.png

3. Result:

Whether this result meets your expectations

vyangliumsft_2-1674110729825.png

 

Best Regards,

Liu Yang

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

Thanks, but this only works if Date is included in the table. It does not work if you wish to use the measure to filter other visual where Date is not contained. 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.