如何防止Power BI线图在某些时间间隔没有值时绘制穿越时间序列点的线条?

huangapple go评论58阅读模式
英文:

How do I prevent Power BI line chart drawing a line through time series points when there is no value for some intervals?

问题

我在Power BI中创建了一张折线图,用于可视化以下虚构数据。

如您在第三行中所见,WF在2022年没有值,但在2023年有一个值为12。当我绘制WF的年份值以及全国平均值时,Power BI会在2021年(10)到2023年(12)之间为WF绘制一条直线。然而,如果某个年份没有值,我不希望绘制一条线穿过该年份。我只想让线停在2021年,并在2023年的值上绘制一个点。

我已尝试将x轴从连续变量更改为分类变量,但没有任何变化。

在Power BI中绘制上述数据的折线图

请问有人能帮忙解决这个问题吗?

英文:

I have created a line chart in Power BI to visualise the following fictional data.

**LA Year Value**
WF 2020 4
WF 2021 10
WF 2022
Hac 2020 6
Hac 2021 23
Hac 2022 28
Har 2020 3
Har 2021 8
Har 2022 10
Hac 2023 11
WF 2023 12
Har 2023 5

As you can see in the third row, there is no value for WF in 2022 but further down WF has a value of 12 in 2023. When I plot WF values by year and also national average values, Power BI draws a straight line for WF from 2021 (10) through 2022 to 2023(12). However, I do not want a line to be drawn through 2022 if a value does not exist. I just want the line to stop at 2021 and plot a dot for the 2023 value.

Line chart plot of above data in Power BI

Can anyone help with this please?

I have tried changing the x axis from continuous to categorical but that did not make a difference.

答案1

得分: 0

我已经成功解决了这个问题,经过一些搜索,我能够绘制一条断裂的线,方法如下:

  1. 将x轴从连续变为分类(确保年份是数字而不是文本)。

  2. 然后右键单击可视化,按年份排序。

2021年值和2023年值之间的线将消失,2023年值将绘制为单个点。就是这样!希望这对某人有用。

英文:

I have managed to resolve this with a bit of digging around. I was able to plot a broken line but doing the following.

  1. Change the x-axis from continuous to categorical. (Ensure that the Year is a number and not text).

  2. Then right click on the visual and sort by Year.

The line between the 2021 value and the 2023 value will disappear and a single point will be plotted for 2023 value. That's it! Hopefully this will be useful to someone.

huangapple
  • 本文由 发表于 2023年7月4日 20:55:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76612880.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定