Forum Discussion

H3nning's avatar
H3nning
Helper V
4 years ago
Solved

Replacing missing data with 0 but keeping filter

Hi,   I want to build a line chart. In that chart i plot the values of a column. I have data for 2 years.   In addition i have a timetable with all days from 2010 unteil 2030. I use this as a tim...
  • PaulDBrown's avatar
    PaulDBrown
    4 years ago

    The reason you are seeing the seeing the line into the dates without a value is because your Timeline table includes dates upto 2030 (so you will be a 0 value in the chart for dates in 2022 with no bookings.

    The way to solve this is to change the measure so that it filters out the future dates with no values-

    For example (my Timeline Table is Called Calendar Table)

    Sum +0 (cutoff) =
    VAR _MaxDate =
        CALCULATE (
            LASTNONBLANK ( 'Calendar Table'[Date], [Sum Sales] ),
            ALL ( 'Calendar Table'[Date] )
        ) // Calculates the last date in the data table which has a value
    VAR _RWS =
        FILTER ( 'Calendar Table', 'Calendar Table'[Date] <= _MaxDate ) // creates a table of dates upto and including the last date with a value
    RETURN
        IF ( COUNTROWS ( _RWS ) = 1, [Sum Sales] + 0 )
    // The sum + 0 is applied to dates on or before the max date with a value, if not returns blank
    

    You can now also use the continuous x-axis setting