I'm trying to expand columns after converting to a table, but these columns need to be expanded dynamically.
I've researched online but the code I'm adding just does not work one way or another. I must be missing something but i am not sure.
This is my code:
let
Date = DateTime.ToText((DateTime.LocalNow()), "yyyy-MM-dd"),
Date2 = Date.ToText((Date.AddDays(Date.From(DateTime.FixedLocalNow()),-90)), "yyyy-MM-dd"),
Source = Json.Document(Web.Contents("https://www.findmyshift.com/staff-view?r=2rr67u5y9i&apikey=***********&format=json&start=" & Date2 & "&finish=" & Date)),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", List.Accumulate(#"Converted to Table"[Column1], {}, (state, current) => List.Union({state, Table.ColumnNames(current)}))),
#"Replaced Value" = Table.ReplaceValue(#"Expanded Column1","'","'",Replacer.ReplaceText,{"Column1.Name"}),
#"Renamed Columns" = Table.TransformColumnNames(#"Replaced Value", (columnName as text) as text => Text.Replace(columnName, "Column1.", ""))
Any help would be greatly appreciated.