Forum Discussion
Unpivoting challenge (multiple Excel files with multiple spreadsheets from a Sharepoint folder)
- 4 years ago
Thank you wdx223_Daniel ,
it does work, but the result is not exactly what I expected.
I adapted your code in this way:
let Source = SharePoint.Files("my Sharepoint path", [ApiVersion = 15]), #"Filtered Rows" = Table.SelectRows(Source, each Text.StartsWith([Name], "my text filter")), custom1=Table.Combine(List.TransformMany(#"Filtered Rows"[Content],each Excel.Workbook(_)[Data],(x,y)=>Table.UnpivotOtherColumns(y,{"Column1","Column2","Column3"},"End of Mounth","Value"))) in custom1and this is the result
At the end I solved my need with the following solution
let Source = SharePoint.Files("my Sharepoint url", [ApiVersion = 15]), #"Filtered Rows" = Table.SelectRows(Source, each Text.StartsWith([Name], "my text filter")), WorkbookList = List.Transform(#"Filtered Rows"[Content], each Excel.Workbook(_)[Data]), SpreadsheetList = List.Combine(WorkbookList), TransformTable = (SpreadsheetList as list) as list => let TransformedTable = List.Transform( SpreadsheetList, each Table.UnpivotOtherColumns( Table.PromoteHeaders(_, [PromoteAllScalars=true]), {"Col1", "Col2", "Col3"}, "Attribute", "Value")) in TransformedTable, SpreadsheetTable = Table.Combine(TransformTable(SpreadsheetList)) in SpreadsheetTableThank you again wdx223_Daniel for your answer, because helped me to understand better iterations in M, you deserve a Kudos!
m
let
source=Folder.Files("your folder path"),
custom1=Table.Combine(List.TransformMany(source[Content],each Excel.Workbook(_)[Data],(x,y)=>Table.UnpivotOtherColumns(y,{the column name list which you do not want to unpivot},"End of Month","Value")))
in custom1
Thank you wdx223_Daniel ,
it does work, but the result is not exactly what I expected.
I adapted your code in this way:
let
Source = SharePoint.Files("my Sharepoint path", [ApiVersion = 15]),
#"Filtered Rows" = Table.SelectRows(Source, each Text.StartsWith([Name], "my text filter")),
custom1=Table.Combine(List.TransformMany(#"Filtered Rows"[Content],each Excel.Workbook(_)[Data],(x,y)=>Table.UnpivotOtherColumns(y,{"Column1","Column2","Column3"},"End of Mounth","Value")))
in
custom1
and this is the result
At the end I solved my need with the following solution
let
Source = SharePoint.Files("my Sharepoint url", [ApiVersion = 15]),
#"Filtered Rows" = Table.SelectRows(Source, each Text.StartsWith([Name], "my text filter")),
WorkbookList = List.Transform(#"Filtered Rows"[Content], each Excel.Workbook(_)[Data]),
SpreadsheetList = List.Combine(WorkbookList),
TransformTable = (SpreadsheetList as list) as list =>
let
TransformedTable = List.Transform(
SpreadsheetList, each
Table.UnpivotOtherColumns(
Table.PromoteHeaders(_, [PromoteAllScalars=true]),
{"Col1", "Col2", "Col3"},
"Attribute", "Value"))
in
TransformedTable,
SpreadsheetTable = Table.Combine(TransformTable(SpreadsheetList))
in
SpreadsheetTableThank you again wdx223_Daniel for your answer, because helped me to understand better iterations in M, you deserve a Kudos!
m