在Google Sheets中,如何通过日期在折线图上对齐两个数据集?

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

In Google Sheets, how can I line up 2 data sets by date on a line chart?

问题

我想创建一个包含两条线的折线图,每条线使用来自不同工作表的数据。这两个工作表都包含日期和数值。日期是重叠的,但起始日期不同。

我的数据如下:

工作表 1

日期 数值
2023年1月1日 100
2023年1月2日 100
2023年1月3日 100
2023年1月4日 100
2023年1月5日 100
2023年1月6日 100
2023年1月7日 100
2023年1月8日 100

工作表 2

日期 数值
2023年1月5日 10
2023年1月6日 15
2023年1月7日 20
2023年1月8日 25
2023年1月9日 30

您可以看到,第一组数据从1月1日到1月8日,而第二组数据从1月5日到1月9日。

我的数据范围是 '工作表 1'!A1:B99,'工作表 2'!A1:B99。当我使用这些数据创建折线图时,来自工作表 1的绘制线 - 第一组数据 - 能够正确绘制。

问题在于图表上的第二条线未根据日期正确放置。线的分布和形状是正确的,但它似乎在图表上的错误位置出现。值从图表的开头开始,就好像忽略了工作表 2的日期列。

例如,工作表 2的第一行是 [2023年1月5日, 10]。它应该在图表的中间绘制,但实际上出现在 [2023年1月1日] 处。

是否有一种方法可以准确绘制这些数据,而不必创建一个新的第三个工作表,将其汇总到一个共享日期列中?

英文:

I would like to create a line chart with 2 lines, each using data from a separate sheet. Both sheets contain dates and values. The dates are overlapping but do not have the same beginning date.

My data looks like this:

Sheet 1

Date Value
1/1/2023 100
1/2/2023 100
1/3/2023 100
1/4/2023 100
1/5/2023 100
1/6/2023 100
1/7/2023 100
1/8/2023 100

Sheet 2

Date Value
1/5/2023 10
1/6/2023 15
1/7/2023 20
1/8/2023 25
1/9/2023 30

You can see that the first set of data goes from Jan 1-Jan 8, and the second set of data goes from Jan 5-Jan 9.

My data range is 'Sheet 1'!A1:B99,'Sheet 2'!A1:B99. When I create a line chart with this data, the plotted line from Sheet 1 - the first data set - is plotted accurately.

The problem is that the second line on the chart is not placed in proper accordance to the date. The distribution and shape of the line are correct, but it appears on the chart in the wrong position. The values start at the beginning of the chart, as if the date column from Sheet 2 is being ignored.

For example, the first row from Sheet 2 is [1/5/2023, 10]. It should be plotted halfway through the chart, but it appears at [1/1/2023] instead.

Is there a way that I can accurately plot this data without having to create a new third sheet which aggregates it all with a shared date column?

答案1

得分: 1

没有疑问,有很多方法可以做到这一点,但关键是X轴的值必须是连续的。

对于这个答案,我使用了:

=query({choosecols(Sheet1!A2:C9,1,2,3);choosecols(Sheet2!A2:C6,1,3,2)})

标题是手动输入的。


数据

在Google Sheets中,如何通过日期在折线图上对齐两个数据集?


图表

在Google Sheets中,如何通过日期在折线图上对齐两个数据集?

英文:

No doubt there are many ways to do this, but the key is that the X-Axis values have to be contiguous.

For this answer, I used:

=query({choosecols(Sheet1!A2:C9,1,2,3);choosecols(Sheet2!A2:C6,1,3,2)})

The headers are entered manually.


DATA

在Google Sheets中,如何通过日期在折线图上对齐两个数据集?


GRAPH

在Google Sheets中,如何通过日期在折线图上对齐两个数据集?

huangapple
  • 本文由 发表于 2023年6月26日 04:35:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76552299.html
匿名

发表评论

匿名网友

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

确定