0
votes

I have a query function :

let ID = () =>

let
    Source = Json.Document(Web.Contents("www.example.com")),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
    #"Converted to Table"

in ID

that outputs a table.

What I'm trying to do is add a column from that table I'm outputting to my main query table.

My problem :

I don't know how to add a column without having to define a function that will apply to each row (as in "Add a Custom Column), and insted just add a premade column.

The solution I came up with :

Add an index column to my main query table and then using the "Costum Column" functionnality to call the Nth row of my ID column as such :

let
    Source = ID(),
    #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each ID()[Column1]{[Index]})
in
    #"Added Custom"

My question :

Isn't there just an existing function that will allow me to do this :

Table.AddPremadeColumn(#"Added Index", "Custom", ID()[Column1])
1

1 Answers

0
votes

You can convert the table to columns (i.e. a list of lists), concatenate {ID[Column1]} and convert the result back to a table:

= Table.FromColumns(Table.ToColumns(#"Added Index")&{ID[Column1]})