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!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi,
I don't know if someone can help with a bit of theory;
Table.Group comparer function,
I have a table with a column 'Test' which contains x ,y or z , local group.
Table.Group(Source, {"Test"} ,
{{"N", each _ }} ,0, (x, y)=>
Number.From( x [Test] = [Test] ) )
I have seen this explained as 'current' versus 'next' but that does not seem to be the case,
it seems whatever the first value is x y or z is taken and then each subsequent value is compared to it
and if true / 1 is returned a new group is started.
Further here a grouping is based on "Unit" and the sum of each group is no larger than 10 , index start = 0;
Table.Group(Atable, {"Index"}, {{"Count", each _}},
0, (x,y)=> Number.From(List.Sum( List.Range( Atable [Unit] , x[Index] , (y[Index] - x [Index]) +1)) > 10 ))
Can someone help with a bit more information or sites dealing with this matter. Even REG's
PQ how does not seem to have a great deal of info, I don't know if C Webb has something if so I haven't found it.
Solved! Go to Solution.
This video from BI Gorilla helps to explain this.
Custom Comparer Function for Table.Group in Power Query M - BI Gorilla
Proud to be a Super User! | |
This video seems helps a lot, thanks for sharing @jgeddes
Seems this may help as well, what I learnt from the tutorial above.
The Table.Group function in Power Query/M is a powerful but complex function, especially when using your custom comparer logic to group data dynamically. Let me break this down and clarify how the comparer function works, based on the examples provided.
Grouping Key: The first argument, {"Test"} or {"Index"}, specifies the column(s) used for grouping. Rows with the same key are grouped together.
Operations: The second argument is a list of operations (e.g., {{"N", each _}}) applied to the grouped rows. These operations define what data is kept or summarized in the output table.
Comparer Function: The optional comparer function determines when to start a new group based on custom logic. This function takes two arguments:
The comparer returns a boolean (true to end the current group and start a new one, or false to continue adding rows to the current group).
Table.Group(Source, {"Test"}, {{"N", each _}}, 0, (x, y) => Number.From(x[Test] = y[Test]))Table.Group(Atable, {"Index"}, {{"Count", each _}}, 0,
(x, y) => Number.From(
List.Sum(List.Range(Atable[Unit], x[Index], (y[Index] - x[Index]) + 1)) > 10
)
)Thank you sorry for not getting back to you sooner.
This video from BI Gorilla helps to explain this.
Custom Comparer Function for Table.Group in Power Query M - BI Gorilla
Proud to be a Super User! | |
Thanks,
RD
This video seems helps a lot, thanks for sharing @jgeddes
Seems this may help as well, what I learnt from the tutorial above.
The Table.Group function in Power Query/M is a powerful but complex function, especially when using your custom comparer logic to group data dynamically. Let me break this down and clarify how the comparer function works, based on the examples provided.
Grouping Key: The first argument, {"Test"} or {"Index"}, specifies the column(s) used for grouping. Rows with the same key are grouped together.
Operations: The second argument is a list of operations (e.g., {{"N", each _}}) applied to the grouped rows. These operations define what data is kept or summarized in the output table.
Comparer Function: The optional comparer function determines when to start a new group based on custom logic. This function takes two arguments:
The comparer returns a boolean (true to end the current group and start a new one, or false to continue adding rows to the current group).
Table.Group(Source, {"Test"}, {{"N", each _}}, 0, (x, y) => Number.From(x[Test] = y[Test]))Table.Group(Atable, {"Index"}, {{"Count", each _}}, 0,
(x, y) => Number.From(
List.Sum(List.Range(Atable[Unit], x[Index], (y[Index] - x[Index]) + 1)) > 10
)
)Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 7 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 24 | |
| 15 | |
| 13 | |
| 12 | |
| 9 |