Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register 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 ) )
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.