Forum Discussion
Show only last 4 weeks
- 4 years ago
The easiest solution I found:
1. Go to Power Query, in your Date table, create a custom column that flags the last 4 weeks:The column is going to return TRUE for all rows that fall in the last 4 weeks, as of current date, and FALSE for the rest
2. Put the Last 4 Weeks Flag measure as a filter on your visual and select true.
This will show only the last 4 weeks of your Date table.
Important note: Currently Power BI has a bug where when you upload the data to Power BI Service the TRUE/FALSE values get converted to -1/0. This will mess up your visual. One option wpuld be to open the report in Service and select -1 in the visual filter since it correcponds to TRUE. Another option would be to change your true/false column into a text column.
Now for the correct sorting:
1. Go to Power Query, in your Date table, create a custom column that concatenates the Year and the Week column. In my case, this would look like this:
2. Then create the following measure:
Sort Week Measure = MIN('Date'[Year Week])3. Since my visual where I want to show the last 4 weeks is of a type line and column chart, I put Sort Week Measure as a line value and make it invisible by using the formatting pane - shapes => customize series => select your sorting measure =>set stroke width to zero, then turn off the data labels.4. Then I sort my visual by the Sort Week Measure in ascending order.
Hi Quiny_Harl,
First please check you need last 3 weeks or 3 Calender weeks of data in viz.
If you select Calenderweeks the complete calendar week is always considered for the period. This means it will start on Saturday and end on Sunday.
If you select Weeks, it just goes back seven days. If the relative date is the last 3 weeks, it just goes back 21 days from the current day.
For Sorting: you can sort this visual by Date Earlist Date which would fix it. Another workaround it to create and use table, where make weeknum as text value and sort them by date.
Now if instead of showing data for last weeks you can do some customization and make it like last 30,60,90 days.
For more help and reference please visit:
If it helps and solve the issue, Please accept it as answer and subscribe to my channel.
Thank you!