cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
magji
Helper I
Helper I

Slicer default selection based on date

I have created a report where it has a slicer Reporting Period, period updates every month with current month.
Is there any way that changes default selection value based on current month because right now the slicer selection stays just like it was in the moment where it was saved and published.

1 ACCEPTED SOLUTION

@magji Right, so the "something else" is whatever you want, so for example:

Column =
  VAR __Year = YEAR(TODAY())
  VAR __Month = MONTH(TODAY())
  VAR __Date = [Date]
RETURN
  IF(YEAR(__Date) = __Year && MONTH(__Date) = __Month,"Current Month",FORMAT(__Date,"mmmm") & YEAR(__Date))

So, this will return "Current Month", "August 2020", "July 2020" ... 


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
Greg_Deckler
Super User IV
Super User IV

@magji Not great way of doing it. You can use a relative date slicer. Or you can create a "flag" column that evaluates to "Current Month" and "Something else" for example and then you set "Current Month" in a slicer based on this column.


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@Greg_Deckler 
Thank you, but the user must be still able to select the previous months.
When the user opens the report in Power Bi they want the slicer automatically be selected in current month.

@magji Right, so the "something else" is whatever you want, so for example:

Column =
  VAR __Year = YEAR(TODAY())
  VAR __Month = MONTH(TODAY())
  VAR __Date = [Date]
RETURN
  IF(YEAR(__Date) = __Year && MONTH(__Date) = __Month,"Current Month",FORMAT(__Date,"mmmm") & YEAR(__Date))

So, this will return "Current Month", "August 2020", "July 2020" ... 


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Helpful resources

Announcements
User Groups Public Preview

Join us for our User Group Public Preview!

Power BI User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

March Update

Check it Out!

Click here to read more about the March 2021 Updates!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.