Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I want to create a variable in my DAX formula.
Var = maxdate= max(DateTable[Date])-7, this should gives me the maxdate from selected slicer in YYYY-MM-DD format but it gives me a numeric value for the date. So when I try to filter DateTable <= maxdate it doesent filter.
If I define the Variable like Date(2021-09-01) everything works fine.
I think I have to pologize, I work in Power Pivot, normally Power BI. And I now realize that these measure doesent act the same. All answers is probably correct. But in Power Pivot it fails when I put -7 in the formula.
If I skip -7 it shows me a results, but I can not find a way to offset my enddate.
HI @Stabben23 ,
You can try below code:-
Measure =
VAR selected_date =
SELECTEDVALUE ( table[date] )
VAR maxx_date =
DATEVALUE ( FORMAT ( selected_date - 7, "YYYY-MM-DD" ) )
RETURN
maxx_date
Thanks,
Samarth
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
@Stabben23 That's odd. I can't replicate that behavior with a date table with a Date column.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
19 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
25 | |
10 | |
10 | |
9 | |
6 |