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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Binway
Helper II
Helper II

Line chart show 0 for missing data and when slicer applied

Hi Folks,

I have a data and date table where I am trying to have the line chart drop to 0 when there is missing data.

month_startingBusinessSales
01/01/2015FloatyMcBoat24
01/02/2015FloatyMcBoat42
01/03/2015FloatyMcBoat16
01/04/2015FloatyMcBoat31
01/05/2015RimRecker1
01/05/2015FloatyMcBoat33
01/06/2015FloatyMcBoat35
01/07/2015FloatyMcBoat158
01/08/2015FloatyMcBoat55
01/09/2015RimRecker3
01/09/2015FloatyMcBoat26
01/10/2015RimRecker78
01/11/2015RimRecker12
01/11/2015FloatyMcBoat23
01/12/2015RimRecker3
01/01/2016RimRecker3
01/01/2016FloatyMcBoat17
01/02/2016RimRecker64
01/02/2016FloatyMcBoat21
01/03/2016RimRecker60
01/03/2016FloatyMcBoat11
01/04/2016RimRecker3
01/04/2016FloatyMcBoat10
01/05/2016RimRecker99
01/05/2016FloatyMcBoat7
01/06/2016RimRecker19
01/06/2016FloatyMcBoat33
01/07/2016RimRecker90
01/07/2016FloatyMcBoat60
01/08/2016RimRecker7
01/08/2016FloatyMcBoat27
01/09/2016FloatyMcBoat189
01/10/2016RimRecker8
01/10/2016FloatyMcBoat49
01/11/2016RimRecker2
01/11/2016FloatyMcBoat25
01/12/2016RimRecker2
01/12/2016FloatyMcBoat34

Whislt the data is at the Month Grain the Date Dim is at the Daily level but I don't think this is causing an issue - a sample of the date dim is below and not complete.

date_actualfirst_day_of_month
01/01/2015 00:0001/01/2015 00:00
02/01/2015 00:0001/01/2015 00:00
03/01/2015 00:0001/01/2015 00:00
04/01/2015 00:0001/01/2015 00:00
05/01/2015 00:0001/01/2015 00:00
06/01/2015 00:0001/01/2015 00:00
07/01/2015 00:0001/01/2015 00:00
08/01/2015 00:0001/01/2015 00:00
09/01/2015 00:0001/01/2015 00:00
10/01/2015 00:0001/01/2015 00:00
11/01/2015 00:0001/01/2015 00:00
12/01/2015 00:0001/01/2015 00:00
13/01/2015 00:0001/01/2015 00:00
14/01/2015 00:0001/01/2015 00:00
15/01/2015 00:0001/01/2015 00:00
16/01/2015 00:0001/01/2015 00:00
17/01/2015 00:0001/01/2015 00:00
18/01/2015 00:0001/01/2015 00:00
19/01/2015 00:0001/01/2015 00:00
20/01/2015 00:0001/01/2015 00:00
21/01/2015 00:0001/01/2015 00:00
22/01/2015 00:0001/01/2015 00:00
23/01/2015 00:0001/01/2015 00:00
24/01/2015 00:0001/01/2015 00:00
25/01/2015 00:0001/01/2015 00:00
26/01/2015 00:0001/01/2015 00:00
27/01/2015 00:0001/01/2015 00:00
28/01/2015 00:0001/01/2015 00:00
29/01/2015 00:0001/01/2015 00:00
30/01/2015 00:0001/01/2015 00:00
31/01/2015 00:0001/01/2015 00:00
01/02/2015 00:0001/02/2015 00:00
02/02/2015 00:0001/02/2015 00:00

I have attempted different DAX code to create the measure with the closest I have come using:

All Amounts =
VAR __min = CALCULATE ( MIN ( MonthlySales[month_starting]), ALL())
VAR __max = CALCULATE ( MAX ( MonthlySales[month_starting]), ALL())
VAR __date = MAX(date_dim[first_day_of_month])
RETURN
SUM(MonthlySales[Sales]) + IF (__date >= __min && __date <= __max, 0)

Which doesn't quite do the job:

chart result.PNG

I am wondering if it is possible to display the data - I have also attempted the show items with no value and the +0 at the end of the code.  

 

Thanks in Advance

1 ACCEPTED SOLUTION

Hi @Binway ,

 

Please change the relationship between your date table and fact table to single direction

 

Capture1.PNG

 

Then use the following measure:

 

New Amounts = 
VAR __min = CALCULATE ( MIN ( MonthlySales[month_starting]), ALLSELECTED(MonthlySales))
VAR __max = CALCULATE ( MAX ( MonthlySales[month_starting]), ALLSELECTED(MonthlySales))
VAR RESULT = IF(MAX(date_dim[first_day_of_month])>=DATE(YEAR(__min-10),MONTH(__min-10),1)&&MAX(date_dim[first_day_of_month])<=__max ,
                        SUM(MonthlySales[Sales])+0) return RESULT

 

Capture2.PNG

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

View solution in original post

14 REPLIES 14
amitchandak
Super User
Super User

@Binway , Try like this

 

All Amounts =
VAR __min = CALCULATE ( MIN ( MonthlySales[month_starting]), ALLSELECTED())
VAR __max = CALCULATE ( MAX ( MonthlySales[month_starting]), ALLSELECTED())
RETURN
calculate(SUM(MonthlySales[Sales]) , filter( date, date_dim[first_day_of_month] >= __min && date_dim[first_day_of_month] <= __max)) + 0

 

 

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

After doing a bit more investigation it looks like a SUMMARIZECOLUMNS may be a viable option

EVALUATE 
SUMMARIZECOLUMNS(date_dim[first_day_of_month],
                    MonthlySales[Business],
                    "QTY", SUM(MonthlySales[Sales])+0
                    )

From what I can tell this produces a "virtual table" of the data that I could perhaps filter where the date_dim dates are within the data range.

But I can't seem to get the filter to work such as wrapping a calculate around it.

 

Thnaks

Binway

Hi @Binway ,

 

Please try to use the following measure:

 

All Amounts =
VAR sales =
    SUMMARIZE (
        MonthlySales,
        MonthlySales[Business],
        date_dim[first_day_of_month],
        "QTY", SUM ( MonthlySales[Sales] ) + 0
    )
RETURN
    SUMX ( sales, [QTY] )

 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

Hi Dedmon,

I was thinking a SUMX with a filter but the missing records are not appearing and the filtere does not work. I even tried ADDMISSINGITEM but can't seem to filter the dates before the Min and Max

EVALUATE
VAR __min = CALCULATE ( MIN ( MonthlySales[month_starting]), ALLSELECTED())
VAR __max = CALCULATE ( MAX ( MonthlySales[month_starting]), ALLSELECTED())
VAR sales =
    SUMMARIZE (
        MonthlySales,
        MonthlySales[Business],
        date_dim[first_day_of_month],
        "QTY", SUM ( MonthlySales[Sales] ) + 0
    )
RETURN
    SUMX(FILTER(date_dim,
        date_dim[first_day_of_month]>= __min 
        &&
        date_dim[first_day_of_month]<= __max
        ),
    sales,[QTY])

Hi @Binway ,

 

Please try to use the following measure:

 

measure =
VAR __min =
    CALCULATE ( MIN ( MonthlySales[month_starting] ), ALLSELECTED () )
VAR __max =
    CALCULATE ( MAX ( MonthlySales[month_starting] ), ALLSELECTED () )
VAR sales =
    SUMMARIZE (
        MonthlySales,
        MonthlySales[Business],
        date_dim[first_day_of_month],
        "QTY", SUM ( MonthlySales[Sales] ) + 0
    )
RETURN
    SUMX (
        FILTER (
            sales,
            date_dim[first_day_of_month] >= __min
                && date_dim[first_day_of_month] <= __max
        ),
        [QTY]
    )

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

Sorry Dedmon - same result where the +0 is just not working if you filter it.  How would I create a "virtual table" with all the missing values, then filter that.

Thanks - appreciate the efforts.

Hi @Binway ,

 

It's better that you can share us some sample pbix file.

 

Best Regards,

Dedmon Dai

Thanks for looking at this.

You should be able to get the pbix from google drive here - LineChartTest 

All I am trying to do is add 0 for the missing values when connected to the date_dim, which works fine but no matter what I do I can't then filter this data down to just display the date values in the data table.

Binway

Hi @Binway ,

 

Please check the permission of the shared file. I can't download it.

 

Best Regards,

Dedmon Dai

Not sure why it did that anyway here is a new link.

https://drive.google.com/file/d/1fqXrM1UZxt-sAOsOHTElOxK12_sPQuyx/view?usp=sharing 

Hi @Binway ,

 

Please change the relationship between your date table and fact table to single direction

 

Capture1.PNG

 

Then use the following measure:

 

New Amounts = 
VAR __min = CALCULATE ( MIN ( MonthlySales[month_starting]), ALLSELECTED(MonthlySales))
VAR __max = CALCULATE ( MAX ( MonthlySales[month_starting]), ALLSELECTED(MonthlySales))
VAR RESULT = IF(MAX(date_dim[first_day_of_month])>=DATE(YEAR(__min-10),MONTH(__min-10),1)&&MAX(date_dim[first_day_of_month])<=__max ,
                        SUM(MonthlySales[Sales])+0) return RESULT

 

Capture2.PNG

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

Thanks so much Demon,

I'll see how it works on the real data.

 

Thanks again.

Binway

Sorry Dedmon but the 0 value is not appearing in the chart.

DedmonResult.PNG

 

I will try a filter for the date in the last line similiar to other formulas and let you know how I go.

Thnaks Amit,

That code is very close.  Unfortuntely the +0 returns all the values in the dim_date which I would have thought the filter code would have taken care of.

chart result.PNG

I changed the final line to add another calculate to try create all the values including 0 and then filter but that is not working either:

All Amounts =
VAR __min = CALCULATE ( MIN ( MonthlySales[month_starting]), ALL())
VAR __max = CALCULATE ( MAX ( MonthlySales[month_starting]), ALL())
VAR __date = MAX(date_dim[first_day_of_month])
RETURN
CALCULATE(CALCULATE(SUM(MonthlySales[Sales]))+0,FILTER( date_dim, date_dim[first_day_of_month] >= __min && date_dim[first_day_of_month] <= __max))

 

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.