Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Dynamic Column Names

I have a Web API endpoint which I want to pull data from it. It is protected with OAuth2. Right now I can successfully pull the data from it but I have to specify the column names. I want the colum...
  • Jimmy801's avatar
    6 years ago

    Hello

     

    substitude this code

    #"Converted Data To Table" = Table.FromList(ReportData, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Report Data" = Table.ExpandRecordColumn(#"Converted Data To Table", "Column1", { "Id", "Name", "Description" })

    with this one

    #"Converted Data To Table" = Table.FromList(ReportData, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    UniqueRecordNames = List.Union( List.Transform(#"Converted Data To Table"[Column1], each  Record.ToTable(_)[Name])),
    #"Expanded Report Data" = Table.ExpandRecordColumn(#"Converted Data To Table", "Column1", UniqueRecordNames )

     this should to the trick. Was not able to test your code, but it should work

    Have fun

    Jimmy