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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.