在 Google Sheet 图表中可视化每月的输入和输出(流量)率

visualize monthly input and output (flow) rates in a Google Sheet chart

我有一张 sheet 的票据数据 - 每行一张票。每张票都有一个开放日期。当工单关闭时,它会得到一个关闭日期。

查看月视图我们有:

我将使用这个作为示例数据:

| opened date | opened month | closed date | closed month |
|:-----------:|:------------:|:-----------:|:------------:|
|  2019-04-03 |    2019-04   |             |              |
|  2019-03-12 |    2019-03   |             |              |
|  2019-03-09 |    2019-03   |             |              |
|  2019-02-12 |    2019-02   |  2019-03-06 |    2019-03   |
|  2019-01-06 |    2019-01   |  2019-05-09 |    2019-05   |
|  2019-01-09 |    2019-01   |             |              |
|  2019-01-12 |    2019-01   |             |              |
|  2019-03-09 |    2019-03   |  2019-04-09 |    2019-04   |
|  2019-02-09 |    2019-02   |             |              |
|  2019-04-12 |    2019-04   |  2019-06-12 |    2019-06   |
|  2019-02-12 |    2019-02   |             |              |
|  2019-04-03 |    2019-04   |  2019-07-09 |    2019-07   |
|  2019-01-12 |    2019-01   |  2019-03-03 |    2019-03   |
|  2019-03-09 |    2019-03   |  2019-05-12 |    2019-05   |
|  2019-04-12 |    2019-04   |             |              |
|  2019-03-12 |    2019-03   |             |              |
|  2019-04-03 |    2019-04   |  2019-07-09 |    2019-07   |
|  2019-03-12 |    2019-03   |  2019-07-03 |    2019-07   |
|  2019-01-09 |    2019-01   |             |              |
|  2019-01-09 |    2019-01   |  2019-05-09 |    2019-05   |
|  2019-02-12 |    2019-02   |             |              |
|  2019-03-09 |    2019-03   |  2019-06-06 |    2019-06   |
|  2019-04-03 |    2019-04   |  2019-05-09 |    2019-05   |
|  2019-04-03 |    2019-04   |             |              |
|  2019-02-03 |    2019-02   |             |              |
|  2019-04-03 |    2019-04   |  2019-06-03 |    2019-06   |
|  2019-03-12 |    2019-03   |             |              |
|  2019-01-03 |    2019-01   |  2019-02-06 |    2019-02   |

如果我手动合并开放日期和关闭日期,我会得到:

|  month  |  type  |
|:-------:|:------:|
| 2019-01 | opened |
| 2019-01 | opened |
| 2019-01 | opened |
| 2019-01 | opened |
| 2019-01 | opened |
| 2019-01 | opened |
| 2019-01 | opened |
| 2019-02 | opened |
| 2019-02 | opened |
| 2019-02 | opened |
| 2019-02 | opened |
| 2019-02 | opened |
| 2019-02 | closed |
| 2019-03 | opened |
| 2019-03 | opened |
| 2019-03 | opened |
| 2019-03 | opened |
| 2019-03 | opened |
| 2019-03 | opened |
| 2019-03 | opened |
| 2019-03 | opened |
| 2019-03 | closed |
| 2019-04 | opened |
| 2019-04 | opened |
| 2019-04 | opened |
| 2019-04 | opened |
| 2019-04 | opened |
| 2019-04 | opened |
| 2019-04 | opened |
| 2019-04 | opened |
| 2019-05 | closed |
| 2019-05 | closed |
| 2019-05 | closed |
| 2019-05 | closed |
| 2019-05 | closed |
| 2019-05 | closed |
| 2019-06 | closed |
| 2019-06 | closed |
| 2019-06 | closed |
| 2019-06 | closed |
| 2019-06 | closed |
| 2019-08 | closed |

我可以把它放在一个枢轴中得到:

|  month  | closed | opened |
|:-------:|:------:|:------:|
| 2019-01 |        |    7   |
| 2019-02 |    1   |    5   |
| 2019-03 |    1   |    8   |
| 2019-04 |        |    8   |
| 2019-05 |    6   |        |
| 2019-06 |    5   |        |
| 2019-08 |    1   |        |

这显示了每个月打开和关闭的数量。我可以将其用作图表的来源:

但这并没有显示每个月有多少开放 - 运行 新开放总数,加上旧开放,减去关闭。如果我手动计算,我会得到:

|  month  | closed | opened | open |
|:-------:|:------:|:------:|:----:|
| 2019-01 |        |    7   |   7  |
| 2019-02 |    1   |    5   |  11  |
| 2019-03 |    1   |    8   |  18  |
| 2019-04 |        |    8   |  26  |
| 2019-05 |    6   |        |  20  |
| 2019-06 |    5   |        |  15  |
| 2019-08 |    1   |        |  14  |

所以,我想知道是否有一种方法可以获取我的源数据并生成数据透视表 table/chart 我正在自动寻找 - 显示每月打开的数量、每月关闭的数量以及打开的数量每个月。

试试这双 运行 总计:

=ARRAYFORMULA(IF(A2:A<>"", 
 IF(A2:A, MMULT(TRANSPOSE((ROW(C2:C)<=
 TRANSPOSE(ROW(C2:C)))*C2:C), SIGN(C2:C)), IFERROR(1/0))-
 IF(A2:A, MMULT(TRANSPOSE((ROW(B2:B)<=
 TRANSPOSE(ROW(B2:B)))*B2:B), SIGN(B2:B)), IFERROR(1/0)), ))


更新:

=ARRAYFORMULA(QUERY(SPLIT(QUERY(IF({B2:B; D2:D}<>"", {B2:B&"♦opened"; D2:D&"♦closed"}, ), 
 "where Col1 is not null", 0), "♦"), 
 "select Col1,count(Col1) group by Col1 pivot Col2 format Col1'yyyy-mm'", 0))


=ARRAYFORMULA({""; IF(F3:F<>"", 
 IF(F3:F<>"", MMULT(TRANSPOSE((ROW(H3:H)<=
 TRANSPOSE(ROW(H3:H)))*H3:H), SIGN(H3:H)), IFERROR(1/0))-
 IF(F3:F<>"", MMULT(TRANSPOSE((ROW(G3:G)<=
 TRANSPOSE(ROW(G3:G)))*G3:G), SIGN(G3:G)), IFERROR(1/0)), )})