The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I have a chart that has a total number of "incidents" and is stacked by type. The manager wants to see this sorted by week number, but also wants to see the past six weeks. Can someone direct me on what I need to do here? Thanks
Solved! Go to Solution.
@CMSGuy ,
make sure you have column Year Week or week start date in your table and create a rank on that
Have these new columns in Date Table, Week Rank is Important in Date/Week Table
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
WeekDay = weekday([Date],2)
Have these new columns in Date Table, Week Rank is Important in Date/Week Table
Week Rank = RANKX('Date','Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX('Date','Date'[Year Week],,ASC,Dense) //YYYYWW format
Then you can have measure like
Last 6 weeks =
var _max = maxx(allselected(Date), Date[Week Rank]) // Or// Maxx(filter(Date, Date[Date] = Today()), Date[Week Rank])
var _min = _max -5
return
calculate([Meausre], filter(Date, 'Date'[Week Rank] >=_min && 'Date'[Week Rank] <=_max))
This measure will work with not filter or when you have range greater than 6 week .
In comment check code for today
If you want to select a date and then want 6 week refer
Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI
Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
https://www.youtube.com/watch?v=pnAesWxYgJ8
@CMSGuy ,
make sure you have column Year Week or week start date in your table and create a rank on that
Have these new columns in Date Table, Week Rank is Important in Date/Week Table
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
WeekDay = weekday([Date],2)
Have these new columns in Date Table, Week Rank is Important in Date/Week Table
Week Rank = RANKX('Date','Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX('Date','Date'[Year Week],,ASC,Dense) //YYYYWW format
Then you can have measure like
Last 6 weeks =
var _max = maxx(allselected(Date), Date[Week Rank]) // Or// Maxx(filter(Date, Date[Date] = Today()), Date[Week Rank])
var _min = _max -5
return
calculate([Meausre], filter(Date, 'Date'[Week Rank] >=_min && 'Date'[Week Rank] <=_max))
This measure will work with not filter or when you have range greater than 6 week .
In comment check code for today
If you want to select a date and then want 6 week refer
Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI
Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
https://www.youtube.com/watch?v=pnAesWxYgJ8
For this part, what is [Measure]?
return
calculate([Meausre], filter(Date, 'Date'[Week Rank] >=_min && 'Date'[Week Rank] <=_max))
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
79 | |
71 | |
48 | |
41 |
User | Count |
---|---|
139 | |
112 | |
72 | |
64 | |
62 |