This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hello I have come across this in a few situations where grouping or working with nested let statements
in these three example the first does not work, the other two , where i have a variable or a named function do,
I wondered if anyone can give me more information or a link to a blog or something on this subject,
Just interested generally;
Table.Group( Source , {"Name"}, {{"Count", each
let
acc = List.Generate( ()=> [ x = 0 , y = [Unit] {0} ] ,
each [x] < List.Count( [Unit] ) ,
each [ x = [x] + 1, y = [y] + [Unit] {x} ] ,
each [y] )
in acc }} ) = [Unit] not found,
= Table.Group( Source , {"Name"}, {{"Count", each
let unt = [Unit] ,
acc = List.Generate( ()=> [ x = 0 , y = unt {0} ] ,
each [x] < List.Count( unt ) ,
each [ x = [x] + 1, y = [y] + unt {x} ] ,
each [y] )
in acc }}
= Table.Group( Source , {"Name"}, {{"Count", (z)=>
let
acc = List.Generate( ()=> [ x = 0 , y = z[Unit] {0} ] ,
each [x] < List.Count( z[Unit] ) ,
each [ x = [x] + 1, y = [y] + z[Unit] {x} ] ,
each [y] )
in acc }} )Solved! Go to Solution.
When you use each inside List.Generate, _ refers to the state record, not the group table. That’s why [Unit] fails it looks for Unit in the wrong scope. If you bind the column first (e.g., unt = t[Unit]) or pass the table explicitly ((t)=>t[Unit]), the reference resolves correctly.
Here's an interesting reference: The Each Keyword in Power Query – Excelguru
Shai Karmani | Data & Analytics
If it helped ✅ please mark as resolved & give a kudo so others can find it too.
When you use each inside List.Generate, _ refers to the state record, not the group table. That’s why [Unit] fails it looks for Unit in the wrong scope. If you bind the column first (e.g., unt = t[Unit]) or pass the table explicitly ((t)=>t[Unit]), the reference resolves correctly.
Here's an interesting reference: The Each Keyword in Power Query – Excelguru
Shai Karmani | Data & Analytics
If it helped ✅ please mark as resolved & give a kudo so others can find it too.
Thanks for the link will have a read.
RD
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.