Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Dicken
Continued Contributor
Continued Contributor

Creating a record from list values

Can someone explain why this works;

 

 

= let nlist =  {  {"One", "1"}, {"Two", "2"}} ,
  a =    nlist{0} {0}, 
  b = nlist{0} {1} 
 in
 [  a = b ]


but this does not ? 

= let nlist =  {  {"One", "1"}, {"Two", "2"}} 
 in  
 [   nlist{0} {0} =   nlist{0} {1} ]

 

I presume to do with a list inside  a record as oppsed to single value ? 

Richrd

]

3 ACCEPTED SOLUTIONS
tayloramy
Community Champion
Community Champion

Hi @Dicken,  

Great question! The short version is: [] creates a record literal, and on the left side of = inside a record the thing must be a field name, not an expression.

 

What’s happening

  • let ... in [ a = b ]
    Inside [], a is treated as the field name (literally the text "a"), and b is an expression whose value becomes that field’s value. So this returns a record like [a = "1"]. The earlier variable named a is not referenced as a value here; it’s just the field’s label.

  • let ... in [ nlist{0}{0} = nlist{0}{1} ]
    Here, nlist{0}{0} is an expression, not a valid field name token. Record literals don’t allow expressions on the left of =. That’s why it errors. It’s not about “list inside a record” vs “single value”; it’s about field-name syntax.

Do this instead, depending on your intent

If you wanted a boolean comparison of the two items:

 
let
    nlist = { {"One", "1"}, {"Two", "2"} }
in
    nlist{0}{0} = nlist{0}{1}

or, if you want the boolean inside a record:

 
 
let
    nlist = { {"One", "1"}, {"Two", "2"} }
in
    [ result = nlist{0}{0} = nlist{0}{1} ]

If you wanted a record with a dynamic field name taken from the list (e.g., field name "One", value "1"):

 
let
    nlist = { {"One", "1"}, {"Two", "2"} },
    key   = nlist{0}{0},    // "One"
    val   = nlist{0}{1},    // "1"
    rec   = Record.AddField([], key, val)
in
    rec

 

 

 

If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.

 

 

 

 

View solution in original post

Jai-Rathinavel
Super User
Super User

Hi @Dicken , 

  • In [ a = b ], the field name a is treated as a static identifier, so it works.
  • In [ nlist{0}{0} = nlist{0}{1} ], you’re asking Power Query to calculate the label first, which it doesn’t allow in that spot.
  • If you want a dynamic field name, you must use Record.AddField.

 

Thanks,

Jai

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

Omid_Motamedise
Super User
Super User

Hi @Dicken 

It is because of general definition of a record.

A rocrd should be including the field name (what is provided befor the equal sign) and then the field value. in your second case, the field name is define as nlist{0} {0} wich is not valied for field name.

 

 


If my answer helped solve your issue, please consider marking it as the accepted solution.

View solution in original post

5 REPLIES 5
v-sshirivolu
Community Support
Community Support

Hi @Dicken ,
Thanks for reaching out to the Microsoft Fabric Community Forum.

Working Example:
let
  nlist = { {"One", "1"}, {"Two", "2"} }
in
  [ nlist{0}{0} = nlist{0}{1} ]

This returns a record where the field name is a static identifier, and the field value is the corresponding value (here, "1").

Non-Working Example:

let
  nlist = { {"One", "1"}, {"Two", "2"} },
  a = nlist{0}{0},
  b = nlist{0}{1}
in
  [ a = b ]
 

This example does not work because, in a record literal, the field name on the left side of the equals sign must be a static identifier, not an expression.

Explanation:

When constructing a record literal using [fieldName = expression], the fieldName must be a static identifier such as a, Name, or Value. Expressions are not allowed as field names.

In the second example, nlist{0}{0} (which evaluates to "One") is used as a field name. However, because this is an expression, Power Query / M does not allow it in a record literal.

The first example is valid because the field is defined with a static identifier (a), and only the value on the right side of the equals sign is generated from an expression.

Omid_Motamedise
Super User
Super User

Hi @Dicken 

It is because of general definition of a record.

A rocrd should be including the field name (what is provided befor the equal sign) and then the field value. in your second case, the field name is define as nlist{0} {0} wich is not valied for field name.

 

 


If my answer helped solve your issue, please consider marking it as the accepted solution.
Jai-Rathinavel
Super User
Super User

Hi @Dicken , 

  • In [ a = b ], the field name a is treated as a static identifier, so it works.
  • In [ nlist{0}{0} = nlist{0}{1} ], you’re asking Power Query to calculate the label first, which it doesn’t allow in that spot.
  • If you want a dynamic field name, you must use Record.AddField.

 

Thanks,

Jai

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





tayloramy
Community Champion
Community Champion

Hi @Dicken,  

Great question! The short version is: [] creates a record literal, and on the left side of = inside a record the thing must be a field name, not an expression.

 

What’s happening

  • let ... in [ a = b ]
    Inside [], a is treated as the field name (literally the text "a"), and b is an expression whose value becomes that field’s value. So this returns a record like [a = "1"]. The earlier variable named a is not referenced as a value here; it’s just the field’s label.

  • let ... in [ nlist{0}{0} = nlist{0}{1} ]
    Here, nlist{0}{0} is an expression, not a valid field name token. Record literals don’t allow expressions on the left of =. That’s why it errors. It’s not about “list inside a record” vs “single value”; it’s about field-name syntax.

Do this instead, depending on your intent

If you wanted a boolean comparison of the two items:

 
let
    nlist = { {"One", "1"}, {"Two", "2"} }
in
    nlist{0}{0} = nlist{0}{1}

or, if you want the boolean inside a record:

 
 
let
    nlist = { {"One", "1"}, {"Two", "2"} }
in
    [ result = nlist{0}{0} = nlist{0}{1} ]

If you wanted a record with a dynamic field name taken from the list (e.g., field name "One", value "1"):

 
let
    nlist = { {"One", "1"}, {"Two", "2"} },
    key   = nlist{0}{0},    // "One"
    val   = nlist{0}{1},    // "1"
    rec   = Record.AddField([], key, val)
in
    rec

 

 

 

If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.

 

 

 

 

Dicken
Continued Contributor
Continued Contributor

Thanks, 
I like the record add filed approach, this came about as I was trying to create reecords from lists
without using Record.FromList, Just to to see. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.