Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin 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.
Hi All,
I have a Date Slicer, wherein I want to have the "Latest Date" selected always.
For this I created a column
SlicerDate= IF(Table[Date]= MAX(Table[Date]),"Latest Date")
And this works fine when I pull this in the slicer and keep it single selected so that the Latest Date is selected always by default.
Now,
I want to calculate the No. of Months till the selected date:
If in the slicer, the latest date is 31-07-2021, then the No. of months should be 7.
I created this measure:
No. of months= MONTH(SELECTEDVALUE(Table[SlicerDate]))
But this is giving error, as I have the "Latest Date" text in this column.
So, how do I calculate the No of months...with the date selected in this slicer?
@amitchandak @Fowmy @Anonymous @daxer-almighty
Please help!
Thanks.
Solved! Go to Solution.
Hey @Tanushree_Kapse ,
if you want to return that as a measure, the following code should do it.
No of month measure =
VAR vLatestDate =
CALCULATE(
MAX( Table[Date] ),
ALL( Table[Date] )
)
VAR vCurrentDate =
MAX( Table[Date] )
VAR vDiff =
DATEDIFF(
vCurrentDate,
vLatestDate,
MONTH
)
RETURN
vDiff
If you want that as a calculated column, this should do it:
No of month column =
VAR vLatestDate = MAX(Table[Date])
VAR vCurrentDate = Table[Date]
VAR vDiff =
DATEDIFF(
vCurrentDate,
vLatestDate,
MONTH
)
RETURN
vDiff
I am not sure if I understand your problem statement correctly, but the error you are getting because the [SlicerDate] Column is actually not the Date type column but a text column.
Try doing this:
SlicerDate= IF(Table[Date]= MAX(Table[Date]),Table[Date])
Hey @Tanushree_Kapse ,
if you want to return that as a measure, the following code should do it.
No of month measure =
VAR vLatestDate =
CALCULATE(
MAX( Table[Date] ),
ALL( Table[Date] )
)
VAR vCurrentDate =
MAX( Table[Date] )
VAR vDiff =
DATEDIFF(
vCurrentDate,
vLatestDate,
MONTH
)
RETURN
vDiff
If you want that as a calculated column, this should do it:
No of month column =
VAR vLatestDate = MAX(Table[Date])
VAR vCurrentDate = Table[Date]
VAR vDiff =
DATEDIFF(
vCurrentDate,
vLatestDate,
MONTH
)
RETURN
vDiff
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 3 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 8 | |
| 6 | |
| 6 |