Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
I have a line chart showing everyday sales. I have filtered it to show last 14 days using the filter pane.
Is there a way to add dynamic filter on the visual for the user to choose the number of days, they want to see the sales for.
For example, on google, you could see this on a line graph where you could filter the data for 1D/5D/1M/1Y and so on by the click of a button
Thanks in advance!
Solved! Go to Solution.
Hi @Anonymous ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
(2) We can create a table.
Slicer = DATATABLE (
"Slicer", STRING,
{
{ "1D" },
{ "5D" },
{ "1M" },
{ "1Y" },
{ "5Y" }
}
)
(3)We can create a measure.
Flag =
var _today=TODAY()
var _flag=SWITCH(TRUE(),
SELECTEDVALUE('Slicer'[Slicer])="1D" && MAX('Table'[Date])<=TODAY() && MAX('Table'[Date]) >= TODAY()-1,1,
SELECTEDVALUE('Slicer'[Slicer])="5D" && MAX('Table'[Date])<=TODAY() && MAX('Table'[Date]) >= TODAY()-5,1,
SELECTEDVALUE('Slicer'[Slicer])="1M" && MAX('Table'[Date])<=TODAY() && MAX('Table'[Date]) >= EDATE(TODAY(),-1),1,
SELECTEDVALUE('Slicer'[Slicer])="1Y" && MAX('Table'[Date])<=TODAY() && MAX('Table'[Date]) >= DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY())),1,
SELECTEDVALUE('Slicer'[Slicer])="5Y" && MAX('Table'[Date])<=TODAY() && MAX('Table'[Date]) >= DATE(YEAR(TODAY())-5,MONTH(TODAY()),DAY(TODAY())),1,
ISFILTERED(Slicer[Slicer])=FALSE(),1,0)
return _flag
(4) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
(2) We can create a table.
Slicer = DATATABLE (
"Slicer", STRING,
{
{ "1D" },
{ "5D" },
{ "1M" },
{ "1Y" },
{ "5Y" }
}
)
(3)We can create a measure.
Flag =
var _today=TODAY()
var _flag=SWITCH(TRUE(),
SELECTEDVALUE('Slicer'[Slicer])="1D" && MAX('Table'[Date])<=TODAY() && MAX('Table'[Date]) >= TODAY()-1,1,
SELECTEDVALUE('Slicer'[Slicer])="5D" && MAX('Table'[Date])<=TODAY() && MAX('Table'[Date]) >= TODAY()-5,1,
SELECTEDVALUE('Slicer'[Slicer])="1M" && MAX('Table'[Date])<=TODAY() && MAX('Table'[Date]) >= EDATE(TODAY(),-1),1,
SELECTEDVALUE('Slicer'[Slicer])="1Y" && MAX('Table'[Date])<=TODAY() && MAX('Table'[Date]) >= DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY())),1,
SELECTEDVALUE('Slicer'[Slicer])="5Y" && MAX('Table'[Date])<=TODAY() && MAX('Table'[Date]) >= DATE(YEAR(TODAY())-5,MONTH(TODAY()),DAY(TODAY())),1,
ISFILTERED(Slicer[Slicer])=FALSE(),1,0)
return _flag
(4) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ohh nevermind,
1) I just added an integer column, "Number" in the table creation query
2) In Column tools pane of "Slicer", changed the Sort by column to "Number"
This works perfectly, just one thing, how do I add an integer column to the slicer table, I want to sort it using that column.
You can simply create identical charts and filter each of them on a specific period. Create a bookmark that will show and hide the charts and link each bookmark to a button that you will llay on top of the charts. P.S. have the charts overlaying each other
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!