简体   繁体   中英

Excel Power Pivot combining multiple sources into column

I have multiple similar data files with a large overlap of similar rows. I'd like to combine them so that a given column from each set appears in a distinct column in a new table. Essentially this is very similar to a standard pivot table where the source is a column field and the values of the field are those of the original files where present.

So for 2 source files:

File 1

在此处输入图片说明

and File 2

在此处输入图片说明

I'd like to end up with:

在此处输入图片说明

So all the common data is in the row and there is one column for each file containing the "Status" (or blank if that row isn't present).

I want to have this as a data source that I can then pivot. Is this possible? I know how to combine the files into a single source using Get Data -> From Folder and I know I can then pivot that data, but it doesn't get me to the final solution above.

Assuming you've got 2 separate queries bringing in data from the 2 source files as listed above, first step would be to add a 'File' column to each of them ie Table.AddColumn(#"Previous Step", "File", each "File 1/2/3 etc", type text) , ie so you end up with: 在此处输入图片说明 and在此处输入图片说明

Then Append the 2 adjusted tables to give you this在此处输入图片说明

Select the 'File' column, go to Transform => Pivot Column and in the pivot window choose 'Status' as the Values column and Don't Aggregate as the Aggregate Function在此处输入图片说明 在此处输入图片说明

Which gives you your desired result在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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