Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

View all the Fabric Data Days sessions on demand. View schedule

Reply
bleow
Frequent Visitor

Display missing data as 0 in line chart

My transformed (unpivoted) data looks like this:

 

IDActivityDateMonth-Year
001OrangeActivity11/11/2020Nov 2020
001BlueActivity13/11/2020Nov 2020
003OrangeActivity4/12/2020Dec 2020
006BlueActivity4/1/2021Jan 2021

 

Setting Month-Year as x-axis and Count of ID as y-axis (and applying a hidden index sort), I get this:

 

bleow_1-1623298926341.png

 

The issue comes for Month-Years that don't have an entry in the data, e.g. Dec 2020 for blue activity. 

 

I tried "Show items with no data", the CALCULATE(... +0) trick and the if 0 then 0 trick, but all didn't seem to work.

 

My last resort I can think of is to generate a calendar table, do a left join, and replace blank values with 0, but that will make my table extremely huge (the date can go back decades), and also means it will keep growing everyday. Is there a better way?

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@bleow , That trick will work if you have a separate date table and use month year from there. 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@bleow , That trick will work if you have a separate date table and use month year from there. 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you so much, this did the trick. I still need a separate date table with all the days (over 500k rows), but with only three columns the processing time is much more manageable than my last resort.

 

For anyone reading this and requiring the same solution:

 

 

 

//new DAX table
DateRange = 
CALENDAR(
      min(Table[Date])
    , max(Table[Date])
)

//new columns
MonthYear = FORMAT([Date], "mmm yyyy")
Index Month-Year = RANKX('5 DateRange', DATE(Year([Date]), MONTH([Date]), "1"), DATE(Year([Date]), MONTH([Date]), "1"), ASC, Dense)

//Select MonthYear in the right Field pane, go to Column tools > Sort by column > Index Month-Year.
//Set MonthYear as x-axis. MonthYear should be sorted by time-series now instead of alphabetically.

 

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors