Forum Discussion
snaise
3 years agoFrequent Visitor
Join all sheets in one excel after transforming them individually
have an excel file with multiple sheets which I want first to transform them individually (remove 3 top rows, promote headers, remove top row, unpivot columns that are not column1=), and then annex t...
- 3 years ago
hi, snaise
1. Create a custom function with all your transformations steps.
2. Read your file with Excel.Workbook(File.Contents("C:\Book1.xlsx"), null, true)
3. Filter [Kind] column to get sheets only.
4. Apply your function to [Data] column: Table.TransformColumns(Source, each {"Data", my_function})
5. Table.Combine [Data] column
So
let Source = Excel.Workbook(File.Contents("C:\Book1.xlsx"), null, true), filter_sheets = Table.SelectRows(Source, each ([Kind] = "Sheet")), my_function = (t as table) => let a = Table.RemoveFirstN(t, 3), b = Table.PromoteHeaders(a), c = Table.RemoveFirstN(b, 1), d = Table.UnpivotOtherColumns(c, {"Column1"}, "Attribute", "Value") in d, transform = Table.TransformColumns(filter_sheets, {"Data", my_function}), combine = Table.Combine(transform[Data]) in combine
snaise
3 years agoFrequent Visitor
Hi Philip, thanks for answering.
The question is that is an excel file were they add each weeks info in a new tab, so do it individually doesn't work for me. I'm looking for a way were you can deal with them as files you combine, with one generic transformation for all of them.