March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Solved! Go to Solution.
hi @Charcoal55 ,
try like:
FILTER(
ALL(Dates),
Dates[Date] <= EDATE(MAX(Dates[Date]), -12)
)
EDATE is not time intelligence function and thus less picky.
hi @Charcoal55 ,
try like:
FILTER(
ALL(Dates),
Dates[Date] <= EDATE(MAX(Dates[Date]), -12)
)
EDATE is not time intelligence function and thus less picky.
Hi @Charcoal55
You're right in thinking that DATEADD can be used to adjust the filter context, but there’s a small issue with how you're applying it in the FILTER function.
In your case, you want to return all dates from 2000 to 2022 when the filter context is for 2023. You can achieve this by shifting the latest date in the context (which is defined by MAX(Dates[Date])) back by one year. Here's the correct approach using DATEADD:
FILTER( ALL(Dates), Dates[Date] <= DATEADD(MAX(Dates[Date]), -1, YEAR) )
This approach is cleaner and avoids hardcoding the date offset (e.g., -365). The DATEADD function handles the exact date subtraction, which accounts for leap years and other complexities.
Please mark this as solution if it helps. Appreciate Kudos.
The problem is that I get the following error message when I am trying the formula you suggest:
"The first argument to 'DATEADD' must specify a column."
I interpret it that since MAX returns a scalar value and that is not acceptable by DATEADD because it requires a column as it's first argument.
@Charcoal55 , Formula is correc
DAX
FILTER(
ALL(Dates),
Dates[Date] <= DATEADD(MAX(Dates[Date]), -1, YEAR)
)
Just ensure that
The Dates table is properly related to other tables in your data model.
The filter context is correctly applied.
There are no syntax errors or other issues in the broader DAX expression where this formula is used.
Proud to be a Super User! |
|
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
25 | |
16 | |
15 | |
7 | |
7 |
User | Count |
---|---|
37 | |
31 | |
16 | |
16 | |
12 |