Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register 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! |
|
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
24 | |
21 | |
18 | |
14 | |
11 |
User | Count |
---|---|
44 | |
35 | |
25 | |
22 | |
22 |