Forum Discussion

smpa01's avatar
smpa01
Community Champion
3 years ago
Solved

Assiginng Record Field Name Dynamically

Is it posible to assign the Record Field name dynamically.

I am currently getting an error.

let
  fieldName = {"a","b"},
  src=[fieldName{0}=1,fieldName{1}=2]
in
    src

 

 

AlexisOlson CNENFRNL  ImkeF 

 

Thank you in advance

  • How about this?

    let
        fieldNames = {"a","b"},
        src=Record.FromList({1,2}, fieldNames)
    in
        src

3 Replies

  • How about this?

    let
        fieldNames = {"a","b"},
        src=Record.FromList({1,2}, fieldNames)
    in
        src
  • Here's another method that's more in the spirit of your attempt but not at nice:

    let
        fieldNames = {"a","b"},
        src=Record.Combine(
            {
                Record.AddField([],fieldNames{0},1),
                Record.AddField([],fieldNames{1},2)
            }
        )
    in
        src