Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
If you group a table in the GUI
1/ the generated code appears as such
Table.Group(#"Kept First Rows", {"Claim ID"}, {{"MinPrice", each List.Min([Contract Price]), type nullable number}})
2/ even though the argument to the 'each' function is a table, you can rewrite the function like the following and it will always work
Table.Group(#"Kept First Rows", {"Claim ID"}, {{"MinPrice", each List.Min(Record.Field(_, "Contract Price")), type nullable number}})
3/ however, rewriting that same code inside a let/in block raises an error
Table.Group(#"Kept First Rows", {"Claim ID"}, {{"MinPrice", each let n = List.Min(Record.Field(_, "Contract Price")) in n, type nullable number}})
Expression.Error: We cannot convert a value of type Table to type Record.
4/ to work inside the let/in block, you need to change from Record.Field to Table.Column like this
Table.Group(#"Kept First Rows", {"Claim ID"}, {{"MinPrice", each let n = List.Min(Table.Column(_, "Contract Price")) in n, type nullable number}})
I get why #3 generates an error. I'm wondering why #2 does not...
Solved! Go to Solution.
Hi @hansei,
I think this should be related to the let-in structure and _ operator.
In the 'group' function, the _ operator after 'each' keyword mapping to the table type, and can be recognized and evaluated after each keyword but these operations seem not processed in the nested let-in structure. (perhaps related to Lazy and eager evaluation)
Evaluation model - PowerQuery M | Microsoft Docs
For your scenario, you can try to use the following formula to fix this issue:
Table.Group(#"Kept First Rows", {"Claim ID"}, {{"MinPrice", each let n = List.Min(_[Contract Price]) in n, type nullable number}})
Regards,
Xiaoxin Sheng
Hi @hansei,
I think this should be related to the let-in structure and _ operator.
In the 'group' function, the _ operator after 'each' keyword mapping to the table type, and can be recognized and evaluated after each keyword but these operations seem not processed in the nested let-in structure. (perhaps related to Lazy and eager evaluation)
Evaluation model - PowerQuery M | Microsoft Docs
For your scenario, you can try to use the following formula to fix this issue:
Table.Group(#"Kept First Rows", {"Claim ID"}, {{"MinPrice", each let n = List.Min(_[Contract Price]) in n, type nullable number}})
Regards,
Xiaoxin Sheng
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 45 | |
| 44 | |
| 20 | |
| 19 |
| User | Count |
|---|---|
| 73 | |
| 71 | |
| 34 | |
| 33 | |
| 31 |