Excel: three steps to get a two-dimensional tables turn one-dimensional table

Note: This article was operational tool Excel 365

 

Introduction omitted two-dimensional table with one-dimensional table, directly to the question, how will excel table into a two-dimensional one-dimensional table?

 

Original two-dimensional table

 

 

 

In data management, typically using one-dimensional table processing and analysis (on this point can understand simple database, data is stored using a database for data management), the original Chinese style classic two-dimensional table to be transformed into one-dimensional table below by step 3 the two-dimensional table into one-dimensional table, look at the data processing one-dimensional table obtained:

 

Processing one-dimensional table obtained

 

 

 

 

Ideas

 

The original two-dimensional table has multiple rows title / header and column header / header, the actual work may exist in more complex cases, consider all the row headers merger , all of the column headings merge , into a simple two dimension tables , the use of reverse flow of the PivotTable, treated two-dimensional table Unpivot , becomes only three (two attributes, a value) of the one-dimensional table, and then the two data split column process, It becomes one-dimensional table, then the data is simply to give the final data .

 

 

 

Tools

 

Use powerquery for conversion into two-dimensional table of one-dimensional table, detailed steps are as follows

 

STEP 01

Click Data> from table / area, loading data into powerquery , uncheck the "table contains the title," the data is loaded into powerquery

 

 

 

STEP 02

在powerquery操作界面,对列1、列2进行合并列操作,合并为1列,选中第1列及第2列(原行头),点击转换>合并列

 

注:此处需添加分隔符,以便后续进行拆分

 

 

 

STEP 03

合并列后,进行行列转置,点击转换>转置

 

 

 

注:转置后若存在列值为空,可点击转换>填充>向下进行向下填充,适用于列标题(头)为合并单元格的情况

 

 

 

STEP 04

转置后将第一行用作标题,点击转化>将第一行用作标题

 

 

 

 

STEP 05

进行第二次合并列,选中第1列及第2列(原列头),点击转化>合并列,数据变为简单的二维表

 

注:此处需添加分隔符,以便后续进行拆分

 

 

 

STEP 06

对处理后的二维表进行逆透视,选中第1列数据,点击转化>逆透视列>逆透视其他列,数据变为仅有3列的一维表

 

 

 

STEP 07

对于仅有3列的一维表,进行拆分列反向操作,将之前合并的值拆分掉

 

注:由于合并列后部门值重复,作为标题的“供应商-产品”中存在部分值后面有后缀(_1)的情况,可通过powerquery中的拆分列或excel中的查找替换进行处理

 

 

 

STEP 08

点击“关闭并上载”保存数据,可在excel中查看到处理得到的数据

 

 

 

STEP 09

最后一步,将数据的表头进行更改,稍作处理变为最终想要得到的数据

 

注:数据中存在在powerquery中加上了后缀(_1)的值,需要进行处理

 

 

以上,为二维表转一维表的简单操作,还有很多别的处理办法,欢迎大家分享。

首发于个人微信公众号【八九子】,有任何问题可随时联系我,邮箱 [email protected]

 

Guess you like

Origin www.cnblogs.com/fanyu2019/p/11058414.html
Recommended