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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
icdns
Post Patron
Post Patron

Measure to ignore the month filter in the Page Filter of a report

Hello, 

 

I want to create a measure that calculates the Year-to-Date (YTD) value for the previous year, where the period will depend on the available dates for the current year. For example, if the data for this year spans from January to March, the measure should return the corresponding YTD values for the same period in the previous year. I have two tables: a date dimension table and a fact table. Additionally, I need this measure to ignore the month filter applied in the report's page filter, which is based on the date dimension.

 

I use this calculation, but it ONLY ignores the date when it's used as slicers but not the PAGE FILTER. 

CALCULATE(
SUM(FACT[Sales]),SAMEPERIODLASTYEAR(
(DATESYTD('FACT'[Date]))),
KEEPFILTERS(VALUES('DIM_DATE'[Year])),
REMOVEFILTERS('DIM_DATE)
 
Could somebody help me please? Thank you!
2 ACCEPTED SOLUTIONS
danextian
Super User
Super User

Hi @icdns 

 

Assuming you are using a Dates table that's been marked as such, try the following (Set and use date tables in Power BI Desktop😞

Last Date With Data = 
CALCULATE (
    LASTNONBLANK ( Dates[Date], [Total Revenue] ),
    --use ALLSELECTED ( Dates ) to get the max date with data in the current context
    REMOVEFILTERS ( Dates ) 
)
Total Revenue DATESYTD = 
CALCULATE ( [Total Revenue], DATESYTD ( Dates[Date] ) )
Total Revenue DATESYTD LY = 
VAR _lastDateLY =
    EDATE ( [Last Date With Data], -12 )
RETURN
    CALCULATE (
        [Total Revenue DATESYTD],
        SAMEPERIODLASTYEAR ( Dates[Date] ),
        KEEPFILTERS ( Dates[Date] <= _lastDateLY )
    )

You can see in the image below that YTD LY stops in Apr-24 which is the latest period with data

danextian_0-1747307709190.png

 

Even when Apr-24 is selected in the page filter, the correct YTD and YTD LY values are still shown. However, if the goal is to display all months up to and including the selected month, that won’t work. This is because filtering through a slicer or the filter pane—whether on the same table or a related one—restricts the visible rows to the selected values. While DAX measures can change the filter context for calculations, they can’t override which rows are displayed in visuals. Filters from a related or the same table take precedence.

danextian_1-1747307803784.png

 

 

Please see the attached sample pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

Hi @icdns   ,
Thanks for reaching out to the Microsoft fabric community forum. 

Yes,the current YTD Last Year measure is still picking up the page filter (like when “Apr-24” is selected), which is expected because functions like KEEPFILTERSrespect all existing filters, including page-level ones.

To get around this and make the measure ignore that filter, you can use REMOVEFILTERS to clear the context from the Dates table. Here's a version of the measure 

Total Revenue DATESYTD LY (Ignore Page Filter) =
VAR _lastDate =
CALCULATE (
LASTNONBLANK ( Dates[Date], [Total Revenue] ),
REMOVEFILTERS ( Dates )
)
VAR _lastDateLY = EDATE ( _lastDate, -12 )
RETURN
CALCULATE (
[Total Revenue],
DATESYTD ( Dates[Date] ),
SAMEPERIODLASTYEAR ( Dates[Date] ),
Dates[Date] <= _lastDateLY,
REMOVEFILTERS ( Dates )
)


If I misunderstand your needs or you still have problems on it, please feel free to let us know.   

Best Regards, 
Menaka.
Community Support Team  

 

View solution in original post

8 REPLIES 8
danextian
Super User
Super User

Hi @icdns 

 

Assuming you are using a Dates table that's been marked as such, try the following (Set and use date tables in Power BI Desktop😞

Last Date With Data = 
CALCULATE (
    LASTNONBLANK ( Dates[Date], [Total Revenue] ),
    --use ALLSELECTED ( Dates ) to get the max date with data in the current context
    REMOVEFILTERS ( Dates ) 
)
Total Revenue DATESYTD = 
CALCULATE ( [Total Revenue], DATESYTD ( Dates[Date] ) )
Total Revenue DATESYTD LY = 
VAR _lastDateLY =
    EDATE ( [Last Date With Data], -12 )
RETURN
    CALCULATE (
        [Total Revenue DATESYTD],
        SAMEPERIODLASTYEAR ( Dates[Date] ),
        KEEPFILTERS ( Dates[Date] <= _lastDateLY )
    )

You can see in the image below that YTD LY stops in Apr-24 which is the latest period with data

danextian_0-1747307709190.png

 

Even when Apr-24 is selected in the page filter, the correct YTD and YTD LY values are still shown. However, if the goal is to display all months up to and including the selected month, that won’t work. This is because filtering through a slicer or the filter pane—whether on the same table or a related one—restricts the visible rows to the selected values. While DAX measures can change the filter context for calculations, they can’t override which rows are displayed in visuals. Filters from a related or the same table take precedence.

danextian_1-1747307803784.png

 

 

Please see the attached sample pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hello, my YTD last year measure should ignore the page filter at the right side. Thank you.

Hi  @icdns ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster. 

Best Regards, 
Menaka.
Community Support Team 

Hi @icdns   ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution so that other community members can find it easily.

Best Regards, 
Menaka.
Community Support Team  

Hi @icdns ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster. 

Best Regards, 
Menaka.
Community Support Team  

Hi @icdns   ,
Thanks for reaching out to the Microsoft fabric community forum. 

Yes,the current YTD Last Year measure is still picking up the page filter (like when “Apr-24” is selected), which is expected because functions like KEEPFILTERSrespect all existing filters, including page-level ones.

To get around this and make the measure ignore that filter, you can use REMOVEFILTERS to clear the context from the Dates table. Here's a version of the measure 

Total Revenue DATESYTD LY (Ignore Page Filter) =
VAR _lastDate =
CALCULATE (
LASTNONBLANK ( Dates[Date], [Total Revenue] ),
REMOVEFILTERS ( Dates )
)
VAR _lastDateLY = EDATE ( _lastDate, -12 )
RETURN
CALCULATE (
[Total Revenue],
DATESYTD ( Dates[Date] ),
SAMEPERIODLASTYEAR ( Dates[Date] ),
Dates[Date] <= _lastDateLY,
REMOVEFILTERS ( Dates )
)


If I misunderstand your needs or you still have problems on it, please feel free to let us know.   

Best Regards, 
Menaka.
Community Support Team  

 

johnt75
Super User
Super User

You can try

Sales Last Year =
VAR CurrentYear =
    YEAR ( TODAY () )
VAR MaxDate =
    CALCULATE (
        MAX ( 'FACT'[Date] ),
        REMOVEFILTERS (),
        YEAR ( 'FACT'[Date] ) = CurrentYear
    )
VAR DatesToUse =
    DATESBETWEEN (
        'DIM_DATE'[Date],
        DATE ( CurrentYear - 1, 1, 1 ),
        EOMONTH ( MaxDate, -12 )
    )
VAR Result =
    CALCULATE ( SUM ( 'FACT'[Sales] ), DatesToUse )
RETURN
    Result
ryan_mayu
Super User
Super User

@icdns 

i think page filter has the higher priority than measures. You need to remove that in the page filter. 

Maybe you can add that filter as visual filter for other visuals in the sample page or you can edit your measure to achieve the same result.





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

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.