I have a table like this that I got using "combine & edit" option in power query that has information from multiple sheets from multiple .xlsx
files. Sheetnames never change and they'll stay the same, excel files can change.
Now, I want many tables splitting by column1
's value firstkey
. So, I can get multiple tables like this,
I have been Googling to find an answer, still no success. There are threads like this, that requires you to duplicate the original table and filter each value.
However, in my case, I want to automate in a way if I have new .xlsx
files. So, if I get a value Brooklyn Park
instead of Bursville
, it should be filtered based on Column1
's value.
How can I do this Power Query?
EDIT
As requested, original excel sheet for one file,
M
code:
let
Source = Excel_Export,
#"Trimmed Text" = Table.TransformColumns(Source,{{"Column1", Text.Trim, type text}}),
#"Cleaned Text" = Table.TransformColumns(#"Trimmed Text",{{"Column1", Text.Clean, type text}}),
#"Filtered Rows" = Table.SelectRows(#"Cleaned Text", each ([Source.Name] = "Burnsville.xlsx")),
#"Transposed Table" = Table.Transpose(#"Filtered Rows"),
#"Removed Top Rows" = Table.Skip(#"Transposed Table",1),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
#"Renamed Columns" = Table.RenameColumns(#"Promoted Headers",{{"Address", "Address Number"}, {"Column3", "StreetName"}, {"Column4", "City"}})
in
#"Renamed Columns"
I used this code to create a function to automate for each file.
M
function which extracts the data from each sheet in a workbook (in the manner/format that you want) -- and then applying that function to the workbooks you want -- and then combining the result into a table. Kind of like what was done here: stackoverflow.com/q/53365065/8811778. Otherwise, based on the screenshot, it seems like you just want to insert an empty row before each instance offirstKey
inColumn1
-- is that correct? – chillin.xlsx
files when you refresh it? #2 I'm not sure what you mean by multiple tables. It should be possible to insert a blank row before each instance offirstKey
inColumn1
, but it would still load as a single table in Excel. #3 I don't understand what you mean by "if I get a value Brooklyn Park instead of Bursville, it should be filtered based on Column1's value.". How does a new value affect the table? Would it appear in the left column of the table? – chillinFolder.Files
function to get a list of.xlsx
files in a particular folder. Then apply the function to each file. The output would be a column/list ofM
tables, which can then be appended/combined into a single table -- and then that single table gets loaded to your Excel sheet. – chillin