Forum Discussion

letItBept_01's avatar
letItBept_01
New Member
1 year ago
Solved

The Line Chart Breaks Midway

      (I do not read English, so I am posting a machine-translated text from Japanese.) I am trying to change the color of a line chart midway through, and I have successfully done so...
  • MFelix's avatar
    1 year ago

    Hi letItBept_01 ,

     

    You line breaks because the information starts where the other stops meaning that since you do not have any data point for actual in 2025 the line ends in 2024 and does not connect to the other one.

     

    There are a couple of options here:

    Create the following measures:

    Total Value = CALCULATE(SUM('Table'[Percentage]), REMOVEFILTERS('Table'[Notes]))
    
    Actual = CALCULATE(SUM('Table'[Percentage]) , 'Table'[Notes] = "Actual")
    
    Forecast = CALCULATE(SUM('Table'[Percentage]), 'Table'[Notes] = "Forecast")
    
    Target = CALCULATE(SUM('Table'[Percentage]), 'Table'[Notes]= "Target")

     

    Now add the measures to you line chart in the following order:

    1. Total Value
    2. Actual
    3. Forecast
    4. Target

    Then color you total value in a grey color

     

    Second option:

    Do not add the total measure and change the forecast and Target to the following code:

    Forecast update = VAR _MinimunYear = MINX(
    			FILTER(
    				ALL('Table'),
    				'Table'[Notes] = "Forecast"
    			),
    			'Table'[Year]
    		)
    		RETURN
    			IF(
    				SELECTEDVALUE('Table'[Year]) = _MinimunYear - 1,
    				CALCULATE(
    					SUM('Table'[Percentage]),
    					'Table'[Year] = _MinimunYear - 1
    				),
    				CALCULATE(
    					SUM('Table'[Percentage]),
    					'Table'[Notes] = "Forecast"
    				)
    			)
    
    Target Updated = VAR _MinimunYear = MINX(
    			FILTER(
    				ALL('Table'),
    				'Table'[Notes] = "Target"
    			),
    			'Table'[Year]
    		)
    		RETURN
    			IF(
    				SELECTEDVALUE('Table'[Year]) = _MinimunYear - 1,
    				CALCULATE(
    					SUM('Table'[Percentage]),
    					'Table'[Year] = _MinimunYear - 1
    				),
    				CALCULATE(
    					SUM('Table'[Percentage]),
    					'Table'[Notes] = "Target"
    				)
    			)
    
    
    
    

     

    Now add the measures in the following order:

    1. Target Updated
    2. Forecast Updated
    3. Actual

    See PBIX File attach.