Forum Discussion

Hennadii's avatar
Hennadii
Helper IV
5 years ago
Solved

Power Query / M. Create a record with a parameterized field name

Hello experts,

 

I'm looking for a solution to create a record with a custom field name through a function.

I tried to use the following expression for CreateRecord function but it does not work properly.

 

(fieldName) =>
let
    rec = [fieldName = "some value"]
in
    rec

 

In a result, it returns a record with a field named fieldName.

 

But I'm expecting that it returns a record named as the passed parameter in the function - SpecificFieldName.

Is there a way to do it?

 

Thank you in advance!

  • Hi Hennadii 

    (fieldName) =>
    let
        rec = Record.FromList({"some value"}, {fieldName})
    in
        rec

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers 

1 Reply

  • AlB's avatar
    AlB
    Community Champion

    Hi Hennadii 

    (fieldName) =>
    let
        rec = Record.FromList({"some value"}, {fieldName})
    in
        rec

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers