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
Everton_Ramone
New Member

How to set last 2 months as default filter in a power bi dashboard

The user when opening the dashboard needs to see the last 2 months filtered with slicer not selected

if user select any date in slicer, then the graphic should be filtered
 

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Everton_Ramone 

According to your description , you want to default select the last two months in your date table?

Here are the steps you can refer to :

(1)We can click "Get more visual" to add the "Preselected Slicer":

vyueyunzhmsft_0-1669773846307.png

vyueyunzhmsft_1-1669773862155.png

(2)We need to create a table like this:

vyueyunzhmsft_2-1669773888885.png

(3)Then we can create a measure :

Measure = var _slicer_date = SELECTEDVALUE('Date'[Date])
var _max_date = MAXX(ALL('Date') , [Date])
var _last_2_month = EOMONTH( _max_date , -2)+1
var _t =SELECTCOLUMNS(FILTER( ALL('Date') , 'Date'[Date]>= _last_2_month && 'Date'[Date]<=_max_date),"Date",[Date])
return
IF(_slicer_date in _t ,TRUE(),FALSE() )

(4)Then we put thses fields on the visual and we can meet your need:

vyueyunzhmsft_3-1669774223949.png

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

4 REPLIES 4
v-yueyunzh-msft
Community Support
Community Support

Hi , @Everton_Ramone 

According to your description , you want to default select the last two months in your date table?

Here are the steps you can refer to :

(1)We can click "Get more visual" to add the "Preselected Slicer":

vyueyunzhmsft_0-1669773846307.png

vyueyunzhmsft_1-1669773862155.png

(2)We need to create a table like this:

vyueyunzhmsft_2-1669773888885.png

(3)Then we can create a measure :

Measure = var _slicer_date = SELECTEDVALUE('Date'[Date])
var _max_date = MAXX(ALL('Date') , [Date])
var _last_2_month = EOMONTH( _max_date , -2)+1
var _t =SELECTCOLUMNS(FILTER( ALL('Date') , 'Date'[Date]>= _last_2_month && 'Date'[Date]<=_max_date),"Date",[Date])
return
IF(_slicer_date in _t ,TRUE(),FALSE() )

(4)Then we put thses fields on the visual and we can meet your need:

vyueyunzhmsft_3-1669774223949.png

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi, What is the purpose of the Dirty Slicer column and how is it used? 

@v-yueyunzh-msft thanks a lot for your reply, it worked.

 

Is the any way you may share your contact so I can get in touch with you?

Regards

Everton_Ramone
New Member

Sample data.png

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.