Forum Discussion

grimmj's avatar
grimmj
New Member
1 year ago
Solved

Table Field identifier using a variable

Hi all,   this is my first post in this community. Hope I am doing all fine to provide the needed information.   I tried to write a function that extracts data of one (generic) column which consi...
  • jgeddes's avatar
    1 year ago

    Try this code and see if it works for you...

    (fieldname as text, recordProperty as text, delimiter as text) =>
    let
    /* testing data
        fieldname = "FixVersions",
        recordProperty = "name",
        delimiter = "|",
    */
        /* mocking test data */
        tmp0 = Table.FromRecords({
            [Key= 22, Summary="test1", FixVersions = Table.ToRecords(Table.FromRows(
            {   {1, "DC-24-1", "DC-24-1"},
                {2, "DC-24-2", "DC-24-2"},
                {3, "DC-24-3", "DC-24-3"}
            },  {"id", "name", "value"} ))],
            [Key= 23, Summary="test2", FixVersions = Table.ToRecords(Table.FromRows(
            {   {1, "DC-24-1", "DC-24-1"},
                {2, "DC-24-2", "DC-24-2"},
                {3, "DC-24-3", "DC-24-3"}
            },  {"id", "name", "value"} ))]
        }),
        transformListValues = Table.TransformColumns(tmp0, {{fieldname, each Text.Combine(List.Transform(_, each Record.Field(_, recordProperty)), delimiter)}})
    in
        transformListValues