简体   繁体   English

将类别的列转换为Excel中的多行

[英]Convert columns of categories into multiple rows in Excel

I have a spreadsheet of Chamber of Commerce members that looks like this: 我有一个商会成员的电子表格,如下所示:

COMPANY              CATEGORY 1             CATEGORY 2       CATEGORY 3
Ameriprise           Lending Institutions   Banks
Country Inn          Lodging                Hotels           Bed & Breakfast
FirstBanc            Lending Institutions   Banks
Gillespie Fair       Events                 Festivals

That I need to convert—on a new sheet—into this: 我需要在一张新纸上将其转换为:

COMPANY              CATEGORY
Ameriprise           Banks
Ameriprise           Lending Institutions
Country Inn          Bed & Breakfast
Country Inn          Hotels
Country Inn          Lodging
Firstbanc            Banks
Firstbanc            Lending Institutions
Gillespie Fair       Events
Gillespie Fair       Festivals

In a nutshell, I need to produce multiple entries for the Company for every Category that business falls under. 简而言之,我需要为业务所属的每个类别为公司生成多个条目。 Any help would be greatly appreciated. 任何帮助将不胜感激。

In data cleaning world, we call this reshaping a data frame from wide to long. 在数据清理世界中,我们称此为从宽到长重塑数据帧。

And there's a way to do it in Excel. 还有一种在Excel中完成此操作的方法。

  1. Hit this key combination: Alt DP . 按下以下组合键: Alt DP This will bring up PivotTable Wizard (Yup, not many know this.) 这将打开数据透视表向导(是的,没有多少人知道这一点。)

  2. Select Multiple consolidation ranges . 选择Multiple consolidation ranges Click next. 点击下一步。

  3. Select I will create the page fields . 选择I will create the page fields Click next. 点击下一步。

  4. Select your data range. 选择您的数据范围。 Click next. 点击下一步。

  5. Select the location to show to pivot table. 选择要显示到数据透视表的位置。 Click next. 点击下一步。

  6. You'll see a pivot table appearing. 您会看到一个数据透视表。 In the PivotTable Field List, untick Row and Column . 在数据透视表字段列表中,取消选中“ RowColumn

  7. You should be left with count of value and a number. 您应该剩下count of value和数字。 Double click that cell. 双击该单元格。 You'll see a new sheet with your converted data table. 您会看到一个包含转换后的数据表的新工作表。

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

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