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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
safy
Frequent Visitor

Filter last 12 months based on the Year, Month slicer selection

I have 2 slicers - one of them displays year while the other displays the month. I want my entire report to be filtered for the last 12 months based on the selected year and month combination. I have a date table with conitnuous dates. 

 

For Example: Year = 2025 and Month = Jul

Then my report needs to be filtered for the dates starting from 01-Aug-2024 until 30-Jul-2025. 

 

Is the only way is to re-create all measures again by changing the filter context so that they are evaulated for the last 12 months. Is there a way to make this work with just the base measures?

 

Example: If I have measure like this: 

 
BikeSales = CALCULATE (
    COALESCE ( [SalesAmt], 0 ),
    FILTER (
        'Dim Product',
        'Dim Product'[ProductName] = "Bikes"
    )
)

Then should I create another measure like below and similarly for every other measures. 

 

BikeSales P12M =
VAR SelectedDate =
MAX ( 'Dimension Period'[Date] )
VAR StartDate1 =
EOMONTH ( SelectedDate, -12 ) + 1
VAR EndDate1 =
IF (
ISFILTERED ( 'Dimension Period' ),
MAX ( 'Dimension Period'[Date] ),
MAXX (
'Dimension Period',
 'Dimension Period'[Date]
)
)
RETURN
CALCULATE (
COALESCE ( [SalesAmt], 0 ),

FILTER (
        'Dim Product',
        'Dim Product'[ProductName] = "Bikes"
    )

,
FILTER (
ALL ( 'Dimension Period' ),
'Dimension Period'[Date] >= StartDate
&& '01. Dimension Period'[Date] <= EndDate
)
)

 

1 ACCEPTED SOLUTION
Shahid12523
Community Champion
Community Champion

To filter your report for the last 12 months based on the Year and Month slicers without rewriting all measures:
- Create a disconnected date slicer table for Year and Month selections.
- Build a single DAX measure that calculates the date range (from 12 months before the selected year/month to the end of the selected month).
- Use this measure as a visual- or page-level filter to restrict data to that range.
- Keep your base measures unchanged, just apply this filter to visuals

Shahed Shaikh

View solution in original post

3 REPLIES 3
Shahid12523
Community Champion
Community Champion

To filter your report for the last 12 months based on the Year and Month slicers without rewriting all measures:
- Create a disconnected date slicer table for Year and Month selections.
- Build a single DAX measure that calculates the date range (from 12 months before the selected year/month to the end of the selected month).
- Use this measure as a visual- or page-level filter to restrict data to that range.
- Keep your base measures unchanged, just apply this filter to visuals

Shahed Shaikh

Thanks for the suggestion. This works but the dax measure has to be a visual filter and the Date field must be present in the visual. So I have to keep this as a matrix and keep the visual drilled to one level above the date. 

johnt75
Super User
Super User

Helpful resources

Announcements
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.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.