Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi,
Is it possible to get DATEADD to be dynamic based on the number written manually in the filter?
So I have a relative date filter on the page showing last X days, and I want DATEADD to work like this:
DATEADD(
'Date'[Date],
- X,
DAYS
)
Solved! Go to Solution.
@Sperling , refer if these can help
same period based on date range
Last Period =
var _max =maxx(allseleceted(date),date[date])
var _min =maxx(allseleceted(date),date[date])
var datediff1 = datediff(_min,_max,day)
var _maxX = _max-datediff1
var _minX = _min -datediff1
return
CALCULATE(SUM(Sales[Sales Amount]),filter(all(date,date[date]<=_maxX &&date[date]>=_minX)))
Hi @Sperling ,
I created some data:
For example:
To display the past X days of today, we can refer to a parameter to display by selecting the parameter.
Here are the steps you can follow:
1. Modeling – New parameter.
2. Select parameters according to your needs.
3. Create measure.
Flag =
IF(MAX('Table'[Date])>=TODAY()-[Parameter Value]&&MAX('Table'[Date])<=TODAY(),1,0)
4. Place [Flag] in Filters, set is=1, apply filter.
5. Result:
If parameter selection is 5, the data of today and the previous 5 days will be displayed.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
@Sperling , refer if these can help
same period based on date range
Last Period =
var _max =maxx(allseleceted(date),date[date])
var _min =maxx(allseleceted(date),date[date])
var datediff1 = datediff(_min,_max,day)
var _maxX = _max-datediff1
var _minX = _min -datediff1
return
CALCULATE(SUM(Sales[Sales Amount]),filter(all(date,date[date]<=_maxX &&date[date]>=_minX)))
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.