Reputation: 177
I have a slicer having a list of MONTH-YEAR list like this:
Jul-22
Aug-22
Sep-22
Oct-22
...
...
From the above list i want current month to be selected.
I have tried with the code below:-
CurrMonth = if(month([Date])=Month(NOW()),month([Date]))
and got the current month but not able to set in the slicer. any help please...
Upvotes: 0
Views: 2993
Reputation: 2615
CurrMonth =
IF (
SELECTEDVALUE ( [Date] ) = FORMAT ( NOW (), "mmm-yy" ),
[Date],
FORMAT ( NOW (), "mmm-yy" )
)
Upvotes: 0
Reputation: 177
I have found the solution as below:
CurrMonth = if(month([Date])=Month(NOW()),CurMonth,FORMAT([Date], "MMM") & " " & [Year])
and set CurrMonth as the Field of the Slicer.
Upvotes: 0
Reputation: 1388
CurrMonth =
VAR _thismonthstart = DATE(YEAR(TODAY()),MONTH(TODAY()),1)
VAR _thismonthfinish = EOMONTH(_thismonthstart,0)
return
if [Date] >= _thismonthstart && [Date] <= _thismonthfinish then 1 else 0
alternatively, you can use the Filter on the visual
another alternative is to create a custom Special Dates Table which has a cross filter direction both ways with your date table.
Upvotes: 1