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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
letItBept_01
New Member

The Line Chart Breaks Midway

スクリーンショット 2025-02-03 155033.png

 

スクリーンショット 2025-02-03 174504.png

 

(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.

Steps to change the color:

  • I prepared a CSV file as the data source for the line chart.
  • The CSV contains three columns: Year, Percentage, and Notes.
  • In the line chart settings, I set:
    • X-axis → Year
    • Y-axis → Percentage
    • Legend → Notes
  • Then, I customized the color and line style for each value in Notes:
    • VisualizationFormat VisualLines → Adjust settings for each value in Notes.
  • As a result, I successfully applied colors as follows:
    • Actual → Blue
    • Forecast → Orange
    • Target → Pink

Issue:

However, as shown in the screenshot, the line breaks at the transition from "Actual" to "Forecast".
A gap appears in the middle of the chart.

Question:

How can I remove this gap and connect the line smoothly?
Is there a way to ensure continuity in the line chart?

 

---

 

Here is the original Japanese text before translation.▼

 

 

タイトル:
折れ線グラフの途中から途切れてしまう

本文:
※私は英語が読めないため、日本語を機械翻訳した文章を投稿しています。

折れ線グラフにて、途中から色を変えようとしています。
それには成功しました。

色変更の手順は以下のとおりです。
・折れ線グラフ用のデータとしてcsvを用意。
・csvでは Year Percentage Notes の3つの列を用意。
・折れ線グラフでは、「X軸にYear」「Y軸にPercentage」をセット。
・「Notes」を「凡例」にセット。
・視覚化 > ビジュアルの書式設定 > 行 から、「系列」で、Notesの各値ごとに色や線形をセット。

これで、Notesの「Actuarl → 青」「Forecast → オレンジ」「Target → Pink」を実現しました。

しかし、スクリーンショットの通り「ActualからForecastの変わり目」で、線が繋がりません。
途中で空白が出来てしまいます。

この空白を無くして、線をつなげたいと思っています。

この場合、線をつなげる方法はあるのでしょうか。

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

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.

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

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.

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Thank you!
It looks like the verification will take some time, but I'll give it a try.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors