Search code examples
chartspowerbidaxlinechartpowerbi-custom-visuals

Power BI Create Continuous Line Chart at End of Position


I have a line chart which the dark blue line data point ends halfway through the chart, as no future data is yet available.

Is there a way to continue the line throughout the rest of the months on the date X Axis as a straight line with its current end position?

Current measure reads

Actuals = SELECTEDVALUE('Actual Hours'[Average Actual FTE])​

Chart

Dataset

EDIT

Updated Line Chart New Measure Code


Solution

  • To continue the line you should fill blanks for future dates like this:

    Actuals = 
    VAR _LastDate =
        CALCULATE(
            MAX('Table'[month]),
            ALL('Table'),
            NOT(ISBLANK('Table'[value]))
        )
    VAR _Value =
        CALCULATE(
            SUM('Table'[value]),
            'Table'[month] = _LastDate
        )
    RETURN
    SWITCH(
        SUM('Table'[value]),
        BLANK(), _Value,
        SUM('Table'[value])
    )
    

    _LastDate defines last date with non-blank value and _Value gets value for this date. Inside RETURN we fill blanks with _Value and do nothing to non-blanks.

    On my dummy data it looks like: enter image description here