简体   繁体   English

Excel / Google表格将列转置为行标题

[英]Excel/Google Sheets Transpose Column into Row Headers

I have a large amount of website page view data. 我有大量的网站页面浏览数据。 The exported format is: 导出的格式为:

Page    | Date (mm/yy) | View Count
-----------------------------------                                                                
Page 1  | 01/18        | 150                                
Page 1  | 02/18        | 250                                
Page 1  | 03/18        | 350                                
Page 1  | 04/18        | 450
Page 2  | 01/18        | 150                                
Page 2  | 02/18        | 250                                
Page 2  | 03/18        | 350                                
Page 2  | 04/18        | 450

What I would like to do is format the data like this: 我想做的是像这样格式化数据:

Page    | 01/18 | 02/18
-----------------------
Page 1  | 150   | 250                                
Page 2  | 150   | 250                                
Page 3  | 150   | 250                                
Page 4  | 150   | 250                                

What you're after can be done with a Pivot table with a few clicks. 只需单击几下即可通过数据透视表完成操作。

在此处输入图片说明

Best practice in Excel: Excel最佳做法:

  • turn your source data into an Excel Table object with Ctrl-T or Insert > Table 使用Ctrl-T或Insert> Table将您的源数据转换为Excel Table对象
  • with a cell in the table selected, use Insert > Pivot Table 在表格中选中一个单元格后,请使用“插入”>“数据透视表”
  • drag the page into the Rows area 将页面拖到“行”区域
  • drag the date into the Rolumns area 将日期拖到Rolumns区域
  • drag the View Count into the Values area 将“查看计数”拖动到“值”区域

With an Excel Table as the source, when you add more data to your source, you can simply click a cell in the pivot table and use Data > Refresh All to, well, refresh the pivot table. 使用Excel表作为源,当您向源中添加更多数据时,只需单击数据透视表中的单元格,然后使用“数据”>“全部刷新”即可刷新数据透视表。

Just a few clicks, no formulas. 只需单击几下,就没有公式。

=query({A:C}, "select Col1, sum(Col3) where Col3 is not null group by Col1 pivot Col2")

  • pivot does what you wanted pivot做什么你想要的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM