Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have a line chart - it is filtered (filters on this page) by date column. Filter on the page is set to relative date, and show items when the value is in the last 7 days.
The chart is showing only data for the last 7 days, however, it's showing the rest of the days as 0 (May 1st, 2022 - May 9th, 2022 & May 17th - May 31st, 2022); which is incorrect:
1) There are data on May 1st 2022 - May 9th 2022
2) May 17th - 31st is in the future.
Is there a way to show only the 7 days on the chart?
Thank you
Solved! Go to Solution.
For future viewers and reference, it looks like I have a measure with IF (ISBLANK) to account for one of the categories to show 0 and not <BLANK>. So the chart without any data for the rest of the dates, showed 0. Removing that will just show the 7 days chart in x-axis.
Not really a fix, but, sort of the cause of the problem and the workaround.
For future viewers and reference, it looks like I have a measure with IF (ISBLANK) to account for one of the categories to show 0 and not <BLANK>. So the chart without any data for the rest of the dates, showed 0. Removing that will just show the 7 days chart in x-axis.
Not really a fix, but, sort of the cause of the problem and the workaround.
Hi @Anonymous ,
I'm not sure if I understood correctly, but it seems you are not using a "proper" Calendar dimension; if you are using the date column from the facts table, I would recommend you to create a date table (the reason why you should use a date table or date calendar is fully explained in this article by the brilliant Reza Rad: Do You Need a Date Dimension? - RADACAD).
That being said, there are several ways to create a date table you can; my favorite is (keep in mind this code is not mine but I am unsure to who I should give kudos, but it is always used at the company I work - Devscope). If you know how to do it, jump to step 7 or after 🙂
Anyway, here it goes:
1- Copy this code (the 3rd step allows you to switch between "en- US" or "pt-PT" if you need to have it in Portuguese for some reason 🙂 ) :
2- Open Power Query:
3- Create a new blank query:
4- Click on Advanced Editor -> delete the piece of code there (inside the red "circle"):
5 - Paste the previously copied code from step 1 and change the steps P_StartDate and P_EndDate accordingly (i.e., if you want the start date to be "2020, 1, 1" replace the year 2018 by 2020; if you want the end date to be the 31st of December of the current year you may let it be like this, if you want the end date of calendar to be the previous year, you just need to insert a "-1" after Date.Year(P_Today)-1, 12, 31).
6- Click "Done" below, Rename the query to "Calendar" and then "close and apply":
7- Create a relationship between table Calendar and your facts table through "date" field.
8- Either:
-Drag and drop "Day (relative)" to page filters and choose the current (0) and the last 7 (up to -7):
Or
- Drag and drop the filed "date" (from table dimension) to Page filter on filter pane and by choosing "relative" -> in the last 7 days.
I know this was too long (sorry for that) but I believe it can also serve as answer/tutorial to many others that might need help with this subject 🙂
Hope I was of assistance!
Cheers
Joao Marcelino
Ps- Did I answer your question? Mark my post as a solution! Kudos are also appreciated 🙂
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 133 | |
| 88 | |
| 85 | |
| 68 | |
| 64 |