let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,List.Transform(Table.ColumnNames(Source), each {_,type text}))
in
#"Changed Type"
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Apple", type any}, {"Car", Int64.Type}, {"Bob", type any}, {"Comments1", type any}, {"Comments2", type any}, {"Date1", type date}, {"Date2", type date}}),
Headers = Table.ColumnNames(Source),
#"Converted to Table" = Table.FromList(Headers, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
//filter for anything. Here I filter to find the word Comments
#"Filtered Rows" = Table.SelectRows(#"Converted to Table", each Text.Contains([Column1], "Comments")),
ListHeaders = Table.ToList(#"Filtered Rows"),
Count = List.Count(ListHeaders),
Transform = Table.TransformColumnTypes( #"Changed Type", Table.ToRows(Table.FromColumns({ListHeaders, List.Repeat({type text}, Count )})))
in
Transform
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Apple", type any}, {"Car", Int64.Type}, {"Bob", type any}, {"Comments1", type any}, {"Comments2", type any}, {"Date1", type date}, {"Date2", type date}}),
Schema = Table.Schema(#"Changed Type"),
#"Filtered Rows" = Table.SelectRows(Schema, each ([TypeName] <> "Date.Type")),
#"Removed Other Columns" = Table.SelectColumns( #"Filtered Rows",{List.First(Table.ColumnNames(#"Filtered Rows"))}),
ListHeaders = Table.ToList(#"Removed Other Columns"),
Count = List.Count(ListHeaders),
Transform = Table.TransformColumnTypes( #"Changed Type", Table.ToRows(Table.FromColumns({ListHeaders, List.Repeat({type text}, Count )})))
in
Transform