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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
sudeshna_sen_tr
Frequent Visitor

Force the default selection of timeline slicer to latest 4 weeks

I have searched everywhere but was able to get solutions for only force selection by current date.

Requirement : I have a PowerBI report where all the pages have a timeline slicer (Timeline 2.4.0 visual) which allows the user to select year, month, quarter and weeks. I want the default state of this slicer to be set to the latest 4 weeks available (i.e. when the user opens the report, they will see just the last 4 weeks & then they can change it as required).

Caveat 1 : The solutions I noticed catered to latest 4 weeks from the current week (using system date). So if it is 21st Dec today, the solutions I see would give me this week & the last 3 weeks prior to this 21st Dec week. But what I need is the last 4 weeks of my data which might not even have data till the current date. So if my dataset has data till 11th Oct, I want the 11th Oct week plus last 3 weeks before that.

Caveat 2 : Most of the solutions I have seen uses DAX formulas to filter out only the last 4 weeks. However, this won't work for me because many of my visuals have current vs previous period comparisons. So filtering out the previous weeks to keep only the latest 4 weeks will show blanks in all the "previous period" visuals (See images below).

sudeshna_sen_tr_0-1640067677239.pngsudeshna_sen_tr_1-1640067713159.png

The above image shows the correct visual when I manually select the last 4 weeks. I want this to be the default state whenever users open the dashboard.


Is there any way to acheive this in PowerBI?

4 REPLIES 4
parry2k
Super User
Super User

@sudeshna_sen_tr there is no default selection, you just have to make it happen in the measures. 

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

amitchandak
Super User
Super User

@sudeshna_sen_tr , One of the way with week rank in date table

 

Last 4 weeks = CALCULATE(countrows('Table'), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-4 && 'Date'[Week Rank]<=max('Date'[Week Rank]))))

 

same period based on date range
Last Period =
var _max =maxx(date,date[date])
var _min =maxx(date,date[date])
var datediff1 = datediff(_min,_max,day)
var _maxX = _max-datediff1
var _minX = _min -datediff1
return
CALCULATE(SUM(Sales[Sales Amount]),filter(all(date,date[date]<=_maxX &&date[date]>=_minX)))

 

 

new columns in date table
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

I have already implemented the same period/last period concept. I want something for my timeline slicer. I'm not sure if the last 4 weeks can be set for the force selection part

was this resolved? If you have found a solution to this, request you to share here. Thanks!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.