Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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.
Solved! Go to Solution.
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
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.
Please see the attached sample pbix.
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
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
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.
Please see the attached sample pbix.
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
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
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.
Proud to be a Super User!
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 38 | |
| 36 | |
| 30 | |
| 28 |
| User | Count |
|---|---|
| 129 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |