如何将水平数据移至垂直订单项?

发布于 2025-02-13 03:47:00 字数 2642 浏览 0 评论 0 原文

我创建了一个Excel表,其中包含不同的库存项目,这些库存项目保存在不同的物理位置。该表是根据各种库存表编译的。

我的桌子看起来像这样:

-------------------------------------------------------------------------
|Item Name|Item Description|Qty loc1|Qty loc2|Qty loc3|Qty loc4|Qty loc5|
-------------------------------------------------------------------------
|Item 1   |Item 1 Descr    |       2|       4|       5|       3|       1|
-------------------------------------------------------------------------
|Item 2   |Item 2 Descr    |       8|        |       5|        |       1|
-------------------------------------------------------------------------
|Item 3   |Item 3 Descr    |        |       4|        |       3|       1|
-------------------------------------------------------------------------
|Item 4   |Item 4 Descr    |       4|        |       5|        |       1|
-------------------------------------------------------------------------
|Item 5   |Item 5 Descr    |        |        |        |        |        |
-------------------------------------------------------------------------
|Item 6   |Item 6 Descr    |      1 |        |        |        |      3 |
-------------------------------------------------------------------------

我希望我的桌子看起来像这样:

----------------------------------------------
|Item Name|Item Description|Qty     |Loc Name|
----------------------------------------------
|Item 1   |Item 1 Descr    |       2|    Loc1|
----------------------------------------------
|Item 1   |Item 1 Descr    |       4|    Loc2|
----------------------------------------------
|Item 1   |Item 1 Descr    |       5|    Loc3|
----------------------------------------------
|Item 1   |Item 1 Descr    |       3|    Loc4|
----------------------------------------------
|Item 1   |Item 1 Descr    |       1|    Loc5|
----------------------------------------------
|Item 2   |Item 2 Descr    |       8|    Loc1|
----------------------------------------------
|Item 2   |Item 2 Descr    |       5|    Loc3|
----------------------------------------------
|Item 2   |Item 2 Descr    |       1|    Loc5|
----------------------------------------------
|Item 3   |Item 3 Descr    |       4|    Loc2|
----------------------------------------------
|Item 3   |Item 3 Descr    |       3|    Loc4|
----------------------------------------------
|Item 3   |Item 3 Descr    |       1|    Loc5|
----------------------------------------------

等...

在这种情况下,有些位置没有任何项目因此,单元格为空白。
一个项目应只有在任何位置都有任何库存时才有一条线。

我尝试在同一工作簿中制作单独的工作表以使单独的工作表能够提取单元格值,但这不是工作。解决这个问题的最佳方法是什么?这将是什么公式?

I created an Excel table with different Inventory items saved in different physical locations. This table was compiled from various Inventory tables.

My table looks like this:

-------------------------------------------------------------------------
|Item Name|Item Description|Qty loc1|Qty loc2|Qty loc3|Qty loc4|Qty loc5|
-------------------------------------------------------------------------
|Item 1   |Item 1 Descr    |       2|       4|       5|       3|       1|
-------------------------------------------------------------------------
|Item 2   |Item 2 Descr    |       8|        |       5|        |       1|
-------------------------------------------------------------------------
|Item 3   |Item 3 Descr    |        |       4|        |       3|       1|
-------------------------------------------------------------------------
|Item 4   |Item 4 Descr    |       4|        |       5|        |       1|
-------------------------------------------------------------------------
|Item 5   |Item 5 Descr    |        |        |        |        |        |
-------------------------------------------------------------------------
|Item 6   |Item 6 Descr    |      1 |        |        |        |      3 |
-------------------------------------------------------------------------

I would like my table to look like this:

----------------------------------------------
|Item Name|Item Description|Qty     |Loc Name|
----------------------------------------------
|Item 1   |Item 1 Descr    |       2|    Loc1|
----------------------------------------------
|Item 1   |Item 1 Descr    |       4|    Loc2|
----------------------------------------------
|Item 1   |Item 1 Descr    |       5|    Loc3|
----------------------------------------------
|Item 1   |Item 1 Descr    |       3|    Loc4|
----------------------------------------------
|Item 1   |Item 1 Descr    |       1|    Loc5|
----------------------------------------------
|Item 2   |Item 2 Descr    |       8|    Loc1|
----------------------------------------------
|Item 2   |Item 2 Descr    |       5|    Loc3|
----------------------------------------------
|Item 2   |Item 2 Descr    |       1|    Loc5|
----------------------------------------------
|Item 3   |Item 3 Descr    |       4|    Loc2|
----------------------------------------------
|Item 3   |Item 3 Descr    |       3|    Loc4|
----------------------------------------------
|Item 3   |Item 3 Descr    |       1|    Loc5|
----------------------------------------------

and so on...

In this case, some locations DO NOT have any items and hence that cell is blank.
An item should only have a line if there is any inventory in any location.

I tried making a separate worksheet in the same workbook to be able to pull cell values but that didn't work. What would be the best approach to tackle this? What would be the formula for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深陷 2025-02-20 03:47:00

使用power查询

自己做

  • 右键单击桌子和在弹出菜单选择从表/范围... 获取数据。

  • 打开电源查询编辑器。

  • ctrl+left-click 项目描述将其添加到选择中。

  • 右click 项目描述,在弹出菜单中选择 undivot other列

  • left-click value 并将其拖到左侧属性列。

  • 右CLICK value 和在弹出菜单中选择重命名... 并将列重命名为 QTY

  • 类似地,右键单击属性,在弹出菜单中选择重命名... 并将列重命名为 loc名称

  • 右click loc名称和在弹出菜单中选择替换值... 和在替换值对话框中,在 value中查找文本框中,Enter QTY (请注意尾随空间)和按 ok

  • Right-Click LOC名称,在弹出菜单中选择 transform 和在变换弹出菜单中选择大写每个单词

  • select 关闭&在色带中加载

使用M-Code

  • 右键单击您的桌子和弹出窗口菜单选择从表/范围获取数据...

  • 电源查询编辑器打开。

  • 在功能区中,选择高级编辑器并将当前代码替换为以下一个(复制代码,单击框中,然后使用ctrl+a和ctrl+v)。

  • 如有必要,请调整表名和列名。

  • 选择完成

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Item Name", type text}, {"Item Description", type text}, {"Qty loc1", Int64.Type}, {"Qty loc2", Int64.Type}, {"Qty loc3", Int64.Type}, {"Qty loc4", Int64.Type}, {"Qty loc5", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Item Name", "Item Description"}, "Attribute", "Value"),
    #"Reordered Columns" = Table.ReorderColumns(#"Unpivoted Other Columns",{"Item Name", "Item Description", "Value", "Attribute"}),
    #"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Value", "Qty"}, {"Attribute", "Loc Name"}}),
    #"Replaced Value" = Table.ReplaceValue(#"Renamed Columns","Qty ","",Replacer.ReplaceText,{"Loc Name"}),
    #"Capitalized Each Word" = Table.TransformColumns(#"Replaced Value",{{"Loc Name", Text.Proper, type text}})
in
    #"Capitalized Each Word"

  • select 关闭&在色带中加载

Unpivot Using Power Query

enter image description here

Do It Yourself

  • Right-click on your table and in the pop-up menu select Get Data from Table/Range....

enter image description here

  • The Power Query Editor opens.

enter image description here

  • Ctrl+left-click Item Description to add it to the selection.

enter image description here

  • Right-click Item Description and in the pop-up menu select Unpivot Other Columns.

enter image description here

  • Left-click Value and drag it to the left so the column switches places with the Attributes column.

enter image description here

  • Right-click Value and in the pop-up menu select Rename... and rename the column to Qty.

enter image description here

  • Similarly, right-click Attributes and in the pop-up menu select Rename... and rename the column to Loc Name.

enter image description here

  • Right-click Loc Name and in the pop-up menu select Replace Values... and in the Replace Values dialog, in the Value To Find text box, enter Qty (note the trailing space) and press OK.

enter image description here

enter image description here

  • Right-click Loc Name and in the pop-up menu select Transform and in the Transform pop-up menu select Capitalize Each Word.

enter image description here

  • Select Close & Load in the ribbon.

enter image description here

Use the M-Code

  • Right-click on your table and in the pop-up menu select Get Data from Table/Range....

  • The Power Query Editor opens.

  • In the ribbon, select Advanced Editor and replace the current code with the following one (copy the code, click in the box and use Ctrl+A and Ctrl+V).

  • Adjust the table name and the column names if necessary.

  • Select Done.

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Item Name", type text}, {"Item Description", type text}, {"Qty loc1", Int64.Type}, {"Qty loc2", Int64.Type}, {"Qty loc3", Int64.Type}, {"Qty loc4", Int64.Type}, {"Qty loc5", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Item Name", "Item Description"}, "Attribute", "Value"),
    #"Reordered Columns" = Table.ReorderColumns(#"Unpivoted Other Columns",{"Item Name", "Item Description", "Value", "Attribute"}),
    #"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Value", "Qty"}, {"Attribute", "Loc Name"}}),
    #"Replaced Value" = Table.ReplaceValue(#"Renamed Columns","Qty ","",Replacer.ReplaceText,{"Loc Name"}),
    #"Capitalized Each Word" = Table.TransformColumns(#"Replaced Value",{{"Loc Name", Text.Proper, type text}})
in
    #"Capitalized Each Word"

enter image description here

  • Select Close & Load in the ribbon.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文