Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Please I need your help on this,
I need to create a measure to calculate the max date of a table that is between two other dates (Date Slicer)
so for example, if in my slicer I chose a date between 2021/1/20 and 2021/2/18, and my table has these dates
We should take 30/1/2021 that's the max date in the table when the date is between 2021/1/20 and 2021/2/18
Solved! Go to Solution.
Hi , @toum
According to your description, you want to create a date slicer and you need to get the max date in table in the selected date range you selected.
Here are teh steps you can refer to :
(1)This is my test data:
(2)We can click "New Table" to create a date table as a slicer:
Date SLicer = CALENDAR(FIRSTDATE('Table'[Date]) , LASTDATE('Table'[Date]))
(3)Then we can create a measure :
Max Date = var _min_date = MIN('Date SLicer'[Date])
var _max_date = MAX('Date SLicer'[Date])
var _t = FILTER(ALLSELECTED('Table') ,'Table'[Date]>=_min_date && 'Table'[Date]<= _max_date)
return
MAXX(_t ,[Date])
(4)Then we can put the filed we need on the visual and then we can meet your need the result is as follows:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi,
Create a Calendar Table. Create a relationship (Many to One and Single) from the Date column of the Data Table to the Date column of the Calendar Table. Write these measures
Total = sum(Data[Sale])
Farthest date = MAXX(filter(values(Calendar[Date]),[Total]>0),Calendar[Date])
Hope this helps.
@toum MAX('Table'[Date]). Am I missing something? Or maybe:
Measure =
VAR __Date = MAX('Dates'[Date])
VAR __Result = MAXX(FILTER('Table',[Date] < __Date),[Date])
RETURN
__Result
Thank you a lot for your help, but I need to include the min selected date of the slicer too, this means if the slicer is between 5/1/2021 and 10/1/2021 nothing will be returned because in the table there is no date between these 2 dates.
Hi , @toum
According to your description, you want to create a date slicer and you need to get the max date in table in the selected date range you selected.
Here are teh steps you can refer to :
(1)This is my test data:
(2)We can click "New Table" to create a date table as a slicer:
Date SLicer = CALENDAR(FIRSTDATE('Table'[Date]) , LASTDATE('Table'[Date]))
(3)Then we can create a measure :
Max Date = var _min_date = MIN('Date SLicer'[Date])
var _max_date = MAX('Date SLicer'[Date])
var _t = FILTER(ALLSELECTED('Table') ,'Table'[Date]>=_min_date && 'Table'[Date]<= _max_date)
return
MAXX(_t ,[Date])
(4)Then we can put the filed we need on the visual and then we can meet your need the result is as follows:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 40 | |
| 37 | |
| 35 | |
| 34 | |
| 28 |
| User | Count |
|---|---|
| 136 | |
| 99 | |
| 73 | |
| 66 | |
| 65 |