简体   繁体   English

在输入到 Power BI 之前格式化数据

[英]Formatting of Data before input into Power BI

I have been struggling and racking in brain trying to take a set of sales data and easily manipulate it so that is can be read by Power BI and easily managed and manoeuvred around within the powerful program but I keep getting stuck.我一直在努力和绞尽脑汁,试图获取一组销售数据并轻松操作它,以便 Power BI 可以读取这些数据,并在强大的程序中轻松管理和操作,但我一直被卡住。 can someone help, please.See image here below from which I receive my data.有人可以帮忙吗,请参见下面的图片,我从中收到了我的数据。 the SKU and descriptions are all in their own column. SKU 和描述都在它们自己的列中。 from there we have multiple stores in which we sell these products.从那里,我们有多个商店出售这些产品。 they are listed in their columns and split by SOH (stock on hand), Sales (stock qty sold) and NET (value sold).它们列在各自的列中,并按 SOH(现有库存)、Sales(售出库存数量)和 NET(售出价值)划分。 Please, can you think of a way to manoeuvre this data in a way that power BI will understand it?拜托,您能想出一种方法来以 Power BI 能够理解的方式处理这些数据吗?

Exccel Sales Sheet example Excel 销售表示例

From what I see, your initial issue is that your table does not start in cell A1.据我所知,您最初的问题是您的表格不是从单元格 A1 开始的。 Power BI begins reading data in the top left corner of the worksheet, so you should delete the first row (the "leading row") of your worksheet so that it can detect where the table begins. Power BI 开始读取工作表左上角的数据,因此你应该删除工作表的第一行(“前导行”),以便它可以检测表的开始位置。

This guide provides instructions and a video on best practices for preparing Excel data for Power BI: https://docs.microsoft.com/en-us/power-bi/service-excel-workbook-files本指南提供有关为 Power BI 准备 Excel 数据的最佳做法的说明和视频: https : //docs.microsoft.com/en-us/power-bi/service-excel-workbook-files

If you will consistently use a data file with a leading row (one with a title or other information that is not part of the table), there is a way to get Power BI to dynamically read data off other lines in the file.如果您始终使用带有前导行的数据文件(带有标题或不属于表的一部分的其他信息),则有一种方法可以让 Power BI 从文件中的其他行动态读取数据。 This guide walks you through how to set this up: https://powerpivotpro.com/2018/02/power-query-magic-dynamically-remove-leading-rows-columns/本指南将引导您完成如何设置: https : //powerpivotpro.com/2018/02/power-query-magic-dynamically-remove-leading-rows-columns/

We can take advantage of Power Query's features to quickly transform this to a usable dataset.我们可以利用 Power Query 的功能将其快速转换为可用的数据集。 The goal will be to move that vendor information as row data instead of column data, leaving SOH/QtySold/NetInc as three general columns.目标是将供应商信息作为行数据而不是列数据移动,将 SOH/QtySold/NetInc 保留为三个通用列。 We can use Unpivot and Pivot to get it done.我们可以使用 Unpivot 和 Pivot 来完成它。

1) Get rid of that first row. 1)摆脱第一行。 In the 'Home' ribbon, find and click 'Remove Rows' and select 'Remove Top Rows.'在“主页”功能区中,找到并单击“删除行”,然后选择“删除顶部行”。 You'll get a dialog box and you can remove the top 1 row.您将看到一个对话框,您可以删除前 1 行。

2) Promote those headers. 2)提升这些标题。 Also on the home ribbon, find the 'Transform ' button group and click 'Use first row as headers' I made a mock dataset that imitates your data but isn't exactly the same.同样在主页功能区上,找到“转换”按钮组并单击“使用第一行作为标题”我制作了一个模拟数据集,它模仿您的数据但不完全相同。

在此处输入图片说明

3) Ok, we're going to get crazy and to a major unpivot of your data. 3) 好的,我们会变得疯狂,并且要对您的数据进行重大调整。 Switch to the 'Transform' ribbon.切换到“变换”功能区。 Then, select the column header "SOH Vendor 1", scroll to your last column, hold shift, and click the header on that last vendor column.然后,选择列标题“SOH Vendor 1”,滚动到最后一列,按住 shift,然后单击最后一个供应商列上的标题。 This will select all those columns in between.这将选择中间的所有列。

4) With all the vendor columns selected, click 'Unpivot Columns' from the transform ribbon. 4) 选择所有供应商列后,单击转换功能区中的“Unpivot Columns”。 It's in the 'Any Column' button group.它位于“任何列”按钮组中。 All those columns get transformed into just two columns, and your table gets a whole bunch more rows.所有这些列都被转换为两列,而您的表格将获得更多行。

在此处输入图片说明

5) Select the 'Attribute' column -- it's full of what used to be column header names. 5) 选择“属性”列——它充满了以前的列标题名称。 From the Transform ribbon, choose 'Split Column' and in the popup menu, specify 'By Delimiter'.从“转换”功能区中,选择“拆分列”,然后在弹出菜单中指定“按分隔符”。 In the dialog box, create a custom delimiter and use the string 'Vendor' as your delimiter.在对话框中,创建自定义分隔符并使用字符串“供应商”作为分隔符。 Click OK单击确定

在此处输入图片说明

6) your Attribute column get's split into to columns. 6)您的属性列被拆分为列。 One will be full of SOH, Qty Sold, and Net Inc. The other will be filled with vendor id codes.一个将填写 SOH、Qty Sold 和 Net Inc。另一个将填写供应商 ID 代码。 Rename that column to 'Vendor'.将该列重命名为“供应商”。

在此处输入图片说明

7) If 'value' isn't the rightmost column, Reorder the columns so that it is. 7) 如果 'value' 不是最右边的列,则重新排列列的顺序。 Highlight the Attribute - Copy.1 column (that's probably the name, but the column is the one that has SOH/QtySold/NetInc values, if it got named something else.突出显示 Attribute - Copy.1 列(这可能是名称,但该列是具有 SOH/QtySold/NetInc 值的列,如果它被命名为其他名称。

8) click on 'pivot column' and select 'Value' as the value column. 8) 单击“枢轴列”并选择“值”作为值列。

在此处输入图片说明

Presto!快!

You now have a table whose key information is SKU, Date, and Vendor (your table will have description and another date too).您现在有一个表,其关键信息是 SKU、日期和供应商(您的表也会有描述和另一个日期)。 Each one of these has three facts in columns - SOH, Qty, and NetInc.其中每一项都在列中包含三个事实 - SOH、Qty 和 NetInc。 You should be ready to go make awesome stuff!你应该准备好去制作很棒的东西了!

Good luck, Hope it helps.祝你好运,希望有帮助。

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

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