You can use these innovative techniques in Power Query to group dynamically and vary the sizes of the groups based on another column's values.
Custom Column Count-Based Conditional Grouping
Add a Custom Column in which group labels are applied using number ranges, categories, or thresholds.
Use if-else conditions in the M language to assign values dynamically.
Example:
Table.AddColumn(Source, "Group", each if [Value] <= 10 then "Small" else if [Value] <= 50 then "Medium" else "Large")
With this new "Group" column, you can group your categories. Group by Predefined Thresholds from Another Table.
If the thresholds happen in a different table, put together the merged queries to assign dynamic group categories.
Classifier logic (i.e., binary search or conditional joins) can be used to approximate match the values into the correct groups.
Example:
Table.NestedJoin(Source, "Value", ThresholdTable, "MinRange", "Merged", JoinKind.LeftOuter)
Using List Functions for Dynamic Bucketing
If group boundaries vary dynamically, generate a list of boundaries and classify records accordingly.
Example:
List.First(List.Select(Thresholds, each _ >= [Value]))
This ensures flexible grouping that adapts as the thresholds change.