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 dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hey there,
I have a calculation created by datesbetween. I used Today()-7 function for the start and Today() for end date. BUt now I want to change it with a dynamic date which comes from my date slicer. Can anyone help me on this please?
Solved! Go to Solution.
Add the variable in a measure to see whether it returns the correct date
e.g.
Measure MIN_DATE = CALCULATE(MIN('Calendar'[Date]),ALLSELECTED('Calendar'[Date]))
Hi,
Replace today()-7 with min(calendar[date]) and today() with max(calendar[date]). Ensure that the Date slicer is built from the Calendar Table.
Hello @Kira_Net
Considering you have a Calendar table, you need to write 2 measures or variables and call these measures in datesbetween function.
Measure =
var _min_date = CALCULATE(MIN('Calendar'[Date]),ALLSELECTED('Calendar'[Date]))
var _max_date = CALCULATE(MAX('Calendar'[Date]),ALLSELECTED('Calendar'[Date]))
RETURN
I have similar approach for my problem statement to count no. of rows between two dates
but with this solution, its showing me the count of all rows.
Hey @themistoklis Thank you. I used the variable for the start and end date but it still showing me blank on my score card. the calculation works fine when I use today() and today ()-7 for start and end date but it only gives me the last week result. I wanted to create the flexeblity for users to filter out date using slicer.
Add the variable in a measure to see whether it returns the correct date
e.g.
Measure MIN_DATE = CALCULATE(MIN('Calendar'[Date]),ALLSELECTED('Calendar'[Date]))
Create a detached calendar (list of dates).
Drad calender to a slicer with a slicer bar (with min and max range)
Create dax measure ....
VAR mindate = MIN(calandar(date))
VAR maxdate = MIN(calandar(date))
RETURN
DATEDIFF(mindate , maxdate , DAY )
I am not sure if this is exactly what you need, but I hope you can change the value as required.
Please click the thumbs up and accept as solution button. Thank you ! 😎
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 |
---|---|
60 | |
58 | |
56 | |
38 | |
28 |
User | Count |
---|---|
82 | |
62 | |
45 | |
41 | |
40 |