Forum Discussion
Relative date filter - workaround when using text field?
I have a calendar table and want to use the MonthYear data field in a bar chart (September 2020) so only the last 3 months show up. I don't want to keep manually changing it every month so would like to use a relative date filter. Problem is, the MonthYear datafield in my calendar table is a text field so relative date filter does not work.
The only date field in my calendar table is Date and that shows the days as well as the month and year which is not what I want.
Thoughts?
3 Replies
- Greg_DecklerCommunity Champion
Anonymous Any chance you could use custom format strings? https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-custom-format-strings
Otherwise, you would have to create a calculated column that flagged "Last 3 Months" and "Other" and set a normal slicer to "Last 3 Months"
- amitchandakSuper User
Anonymous , You can slicer like this and select default value
Month Type = Switch( True(),
eomonth(Date[Date],0) = eomonth(Today(),0) ,"Current Month" , //This Month
eomonth(Date[Date],0) = eomonth(Today(),-1) ,"Previous Month" , //last Month
eomonth(Date[Date],0) = eomonth(Today(),1) ,"Next Month" , //last Month
[Month Year]
)or
Month Type = Switch( True(),
eomonth(Date[Date],0) >= eomonth(Today(),-3)+1 && eomonth(Date[Date],0) <= eomonth(Today(),-0) ,"Last Three Month" ,
[Month Year]
) - AnonymousNot applicable
Hi Anonymous ,
You do have date column (date type) in calendar table, right?
Then you should be able to use monthyear column as axis and add date column as Relative date filter.
Did i miss something?
Best Regards,
Jay