Power Query - How to merge multiple sheets through common ID without invoking them in separate files?
I made a post previously but I omited too much so I could not make use of help, my apologies.
I have a machine which outputs excel file with information stored in following manner:
* n number of sheets with information about specific material per property (varies between 2-4 so far), with first sheet always being useless to me (always called "Details")
within the sheet:
* row with sheet name
* row of column names
* row of units (accidentally omitted)
* data (majority omited for lack of need)
Each sheet column names are almost the same but carry differnet information (e.g. "Enthalpy" or "Peak Temperature" are not the same; "File Name" and "Name" are the only true same between the sheets.)
Problem I encountered is that sometimes the machine outputs file names in different order between sheets, and occasionally I will have information only on one of the sheets.
All as shown below.
For when they were in correct order I used the script below.
I want to edit it to account for those misplacements, which cannot be through formula in native excel because I pull it into different excel file. I tried doing so through table.combine (no can, merges false same columns), and through Table.NestedJoin (can only merge one by one, which is both a hustle and if I change the number of sheets in the future it will break).
Is there a way to append any number of all of them at once through file name only?
Source = ...
#"Filtered table" = Table.ReplaceValue(Source, each [Data], each Table.Skip(Table.PromoteHeaders(Table.Skip([Data],1)),1), Replacer.ReplaceValue, {"Data"}),
#"Filtered Rows" = Table.SelectRows(#"Filtered table", each [Name] <> "Details"),
pref = Table.CombineColumns( #"Filtered Rows" , {"Name", "Data"}, (x) => Table.ToColumns(Table.DemoteHeaders( Table.PrefixColumns(x{1}, x{0}))), "data"),
#"Change headers"= Table.PromoteHeaders( Table.FromColumns(List.Combine(pref[data]) )),
#"Removed Other Columns" = Table.SelectColumns(#"Change headers",{"Glass transition.File Name", "Glass transition.Midpoint", "Hc.Enthalpy (normalized)", "Hc.Peak temperature", "Peak Integration (enthalpy).Enthalpy (normalized)", "Peak Integration (enthalpy).Peak temperature"}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Removed Other Columns", "Glass transition.File Name", Splitter.SplitTextByEachDelimiter({"_"}, QuoteStyle.Csv, true), {"Material", "Run"}),
in
#"Split Column by Delimiter"
[link] [comments]
Want to read more?
Check out the full article on the original site