Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
348 views
in Technique[技术] by (71.8m points)

powerquery - Combine Same Tab from Multiple Workbooks in One Power Query

I have 32 Spreadsheets which all have the same tab "DashboardQuery". On the tab is a table set up with Metrics and values. The Table name is "QueryData". Below is an image of the 'QueryData' table.

enter image description here

I would like to create a power query that combines the data from each of these spreadsheets into one table which has the metrics as headers and values as rows. Below is desired output of power query.

enter image description here

The query currently is combining the multiple spreadsheets/tables into one and I have so far tried Transpose which gives me the correct layout (metrics as columns) but as there are 32 spreadsheets I end up with 32 of the same column headings.

The Query will pull files from a Folder and each fortnight further spreadsheets will be added from the same named areas eg. There will be multiple rows of the same name.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If all your files are in the same folder, you can load that folder using Home > New Source > File > Folder and choose the folder path where they are saved. Your query should look like this at this point (except you'll have more than three files):

Load from Folder

At this point, select the double down arrow on the Content column to Combine Binaries and choose the worksheet DashboardQuery in the dialogue box.

Combine Binaries

Now all your data should be loaded in and labeled according to the file it came from:

Data Loaded

The trick to getting it into the shape you want now is to pivot on the Metrics column. You'll want to use the Values column for the Values Column and select Don't Aggregate under Advanced options.

Pivot Column

The result should now be in the format you want (you can remove the Source.Name column at this point if you want).

Result


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...