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
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).
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?
@sudeshna_sen_tr there is no default selection, you just have to make it happen in the measures.
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.
@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
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
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
User | Count |
---|---|
94 | |
90 | |
84 | |
76 | |
49 |
User | Count |
---|---|
143 | |
141 | |
109 | |
69 | |
55 |