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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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