Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
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
]
Solved! Go to Solution.
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.
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.
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.
Hi @Dicken ,
Thanks,
Jai
Proud to be a 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.
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.
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.
Hi @Dicken ,
Thanks,
Jai
Proud to be a Super User! | |
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.
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.
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.
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.
| User | Count |
|---|---|
| 20 | |
| 10 | |
| 8 | |
| 8 | |
| 7 |