cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper III

## Top 6 rolling weekly date sorted by most recent

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

1 ACCEPTED SOLUTION
Super User

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

2 REPLIES 2
Super User

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

Helper III

For this part, what is [Measure]?

return
calculate([Meausre], filter(Date, 'Date'[Week Rank] >=_min && 'Date'[Week Rank] <=_max))

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

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

#### Fabric Community Update - August 2024

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

Top Solution Authors
Top Kudoed Authors