Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
datahub
Frequent Visitor

Month Slicer to have all active months selected based on current year

Hi, is it possible to have a month slicer (January up to December) to have preselected all active current year months based for example with last date or max date functions.

 

For example if Max Date is October 1st 2021, Month Slicer should have preselected January up to October, leaving November and December unselected.

Thanks very much.

 

 

5 REPLIES 5
speedramps
Super User
Super User

HI datahub

Please consider this solution and click then thumbs up just for me taking the effort to help.
Also click ACCEPT SOLUTION if it fixes your pronlems.

Create a Calendar table 01Jan21 to 21Dec21.

Then in Power Query use the Calendar table to create a pick list with

Period / Date / Sortseq
Jan  01Jan21  1
Jan  02Jan21  1
Jan  03Jan21  1
etc etc etc
Feb  01Feb21 2
Feb  02Feb21 2
Feb  03Feb21 2
etc etc etc
Dec 29Dec21 12
Dec 30Dec21 12
Dec 31Dec21 12


YTD  01Jan21 -1
YTD  02Jan21 -1
YTD  03Jan21 -1
etc to
YTD 15Oct21 -1

MTD  01Oct21 -2
MTD  02Oct21 -2
MTD  03Oct21 -2
etc to
MTD 15Oct21 -2

 

Then build a relationship between the picklist date and the calendar date and relate any fact tables to the calendar date.

Set the Picklist period sort to the Sortseq

When you add the picklist period to the slicer it will show
MTD, YTD, Jan, Feb, Mar, May,  etc in the correct sequence.

When the user selects YTD then the relationship will filter just the required dates.
 
There are lot of examples on Youtube how to do this.

 

amitchandak
Super User
Super User

@datahub , Function base selection is not supported yet, You can vote for an idea or log a new one  -https://ideas.powerbi.com/ideas/

 

The work around as of now is in Date table have a new column

Month Type = Switch( True(),
eomonth([Date],0) <= eomonth(Today(),0) && year([Date]) = Year(Today()),"Active Months" ,
Format([Date],"MMM-YYYY")
)

 

and use that

Hi @amitchandak  Thanks, tried solution, close but is there the possibility to have the current year active months all selected (checked) on the slicer and leave November and December unselected (unchecked) but still present in the slicer (this is because fact table has other past years with data as well) So end user could select them as well to analize other years as well.
Data will be refreshed every month, so idea is to always autoselect (autocheck) only current year´s months with data available. 

Here is a screenshot with the desired solution (next month, November should appear checked as well when data is refreshed)

datahub_1-1634314343115.png

Thanks.

HI @datahub,

AFAIK, current power bi does not include any features to dynamic active specific items in the slicer based on conditions.

For your requirement, you can add a calculated column to your table to check records based on conditions and remark tags. Then you can use this field on the report page to filter specific items. (they will not activate the slicer items, but the filter effect will be applied to the records)
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thanks  @amitchandak I will give it a try.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.