Forum Discussion
Previous month selected automatically from drop-down slicer
- 4 months ago
However I was hoping the slicer display would still show the 'Mar-26' date in the slicer instead of 'previous Month.' Unfortunately, this is not possible. The key of this workaround is being alphabetically different and always be on top of the slicer. Maybe you can add
var _monthName = FORMAT(_previosMonthEnd, "MMMM")
and
"Previous Month (" & _monthName & ")".
If this solved your issue, please mark it as the accepted solution. ✅
Hello chillpill ,
Yes, there is a workaround for this. Let me explain how.
In your date table you should create a new calculated column. If it is from sql you should add a column or you can add it in your power query too.
Step 1- Create a new column in date table.
You should create a new calculated column. I made it dynamic and it calculates on today's date. You can change. As an example:
PM Column =
VAR _today = TODAY()
VAR _previosMonthStart = EOMONTH(_today, -2) + 1
VAR _previosMonthEnd = EOMONTH(_today, -1)
RETURN
IF(
'Dim Date'[Date] >= _previosMonthStart && 'Dim Date'[Date] <= _previosMonthEnd,
"Previous Month",
FORMAT('Dim Date'[Date], "yyyy-mm")
)
Step 2- Change the column in the slicer with the new calculated column. And sort by descending. With sorting descending, previous month stays always at the top.
Step 3- Publish to service with previous month selected. In calculated column, previous month updates dynamically and it opens always with previous month selected.
If this solved your issue, please mark it as the accepted solution. ✅
This is a great solution and what I've seen elsewhere, thank you! However I was hoping the slicer display would still show the 'Mar-26' date in the slicer instead of 'previous Month.' Although now that I think about the sort order of the slicer being based on that calculated column, maybe I can dynamically update that column to order by 1, 2, 3, etc based on the month and do it that way. Thanks for the idea!
- anilelmastasi4 months ago
Super User
However I was hoping the slicer display would still show the 'Mar-26' date in the slicer instead of 'previous Month.' Unfortunately, this is not possible. The key of this workaround is being alphabetically different and always be on top of the slicer. Maybe you can add
var _monthName = FORMAT(_previosMonthEnd, "MMMM")
and
"Previous Month (" & _monthName & ")".
If this solved your issue, please mark it as the accepted solution. ✅