Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello -
How to set default values dynamically for the slicer? E.g. At any moment we want to set only most recent 5 days to the below screenshot slicer visual. So if today is 01/10/2023 then from should be 01/06/2023 and to should be 01/10/2023.
Any help how to set it?
Thank You in advance
Regards,
gk03
Solved! Go to Solution.
Hi , @kgandhi2001
According to your description, you want to "set default values dynamically for slicer".
Here are teh steps you can refer to :
(1)For the slicer that comes with Power BI, we can not get it. But we can get the three point in the "Visualizations", and we click the "Get more visual":
Then we find the "Preselected Slicer" and add the visual to our Power Bi Desktop.
First , we need to create a table with one column , and the value is True and False, like this:
Second , we can create a measure to define which the date we need to default preselected. If we need to default preselect then we return True else return False.
Flag = var _date =SELECTEDVALUE('Date'[Date])
var _today = TODAY()
var _last_5_days = _today -4
return
IF(_date>= _last_5_days , TRUE(),FALSE())
Then we can default dynamic preslect the last three months in the slicer visual , and when we select other date, we just need to click the red reset button in the upper right corner to recover the defalt selections.
You can also refer to this:
Solved: How to set last 2 months as default filter in a po... - Microsoft Power BI Community
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 , @kgandhi2001
According to your description, you want to "set default values dynamically for slicer".
Here are teh steps you can refer to :
(1)For the slicer that comes with Power BI, we can not get it. But we can get the three point in the "Visualizations", and we click the "Get more visual":
Then we find the "Preselected Slicer" and add the visual to our Power Bi Desktop.
First , we need to create a table with one column , and the value is True and False, like this:
Second , we can create a measure to define which the date we need to default preselected. If we need to default preselect then we return True else return False.
Flag = var _date =SELECTEDVALUE('Date'[Date])
var _today = TODAY()
var _last_5_days = _today -4
return
IF(_date>= _last_5_days , TRUE(),FALSE())
Then we can default dynamic preslect the last three months in the slicer visual , and when we select other date, we just need to click the red reset button in the upper right corner to recover the defalt selections.
You can also refer to this:
Solved: How to set last 2 months as default filter in a po... - Microsoft Power BI Community
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
this solution is good but it seems that doesn't support dynamic M query parameters
@DimaMD - Can you please share your DAX function? What should be for [measure]? I posted screenshot in my previous response.
Hello DimaMD
I was not following your DAX logic. it is throwing an error
@kgandhi2001 hi try it
CALCULATE(
[measure],
DATEADD('dates'[Date],
-5,
DAY)
)
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
92 | |
83 | |
71 | |
49 |
User | Count |
---|---|
143 | |
120 | |
110 | |
59 | |
57 |