Forum Discussion
Merge specific tabs excelfiles SharePoint Folder
- 2 years ago
If you want to select the third tab from every file that has four tabs you could do something like...
add a column that gives the excel content for each file
= Table.AddColumn(PREVIOUSSTEP, "_excelContent", each Excel.Workbook([Content]))clicking in either row in the '_excelContent' column will show the listing of sheets, tables etc for that file...
We are only concerned with 'Sheets' so I used a nested function to filter the nested tables to include only 'Sheets'...
fxSelectRows = (inputTable as table) as table => let source = inputTable, selectSheets = Table.SelectRows(inputTable, each [Kind] = "Sheet") in selectSheets= Table.TransformColumns(PREVIOUSSTEP, {{"_excelContent", each fxSelectRows(_)}})you now have only 'Sheets'
Now we only want rows in our table to include files with four tabs...
= Table.SelectRows(PREVIOUSSTEP, each List.Count(Table.ToRows([_excelContent])) = 4)now we only want the third tab...
= Table.TransformColumns(PREVIOUSSTEP, {{"_excelContent", each Table.Range(_, 2, 1)}})and you end up with...
from here you can combine the files into a single table and you are all set.
If you want to select the third tab from every file that has four tabs you could do something like...
add a column that gives the excel content for each file
= Table.AddColumn(PREVIOUSSTEP, "_excelContent", each Excel.Workbook([Content]))
clicking in either row in the '_excelContent' column will show the listing of sheets, tables etc for that file...
We are only concerned with 'Sheets' so I used a nested function to filter the nested tables to include only 'Sheets'...
fxSelectRows =
(inputTable as table) as table =>
let
source = inputTable,
selectSheets = Table.SelectRows(inputTable, each [Kind] = "Sheet")
in
selectSheets
= Table.TransformColumns(PREVIOUSSTEP, {{"_excelContent", each fxSelectRows(_)}})
you now have only 'Sheets'
Now we only want rows in our table to include files with four tabs...
= Table.SelectRows(PREVIOUSSTEP, each List.Count(Table.ToRows([_excelContent])) = 4)
now we only want the third tab...
= Table.TransformColumns(PREVIOUSSTEP, {{"_excelContent", each Table.Range(_, 2, 1)}})
and you end up with...
from here you can combine the files into a single table and you are all set.