cancel
Showing results for 
Search instead for 
Did you mean: 
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

3 REPLIES 3
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

@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
May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.

Top Solution Authors