top of page

Excel Arena

This is the place, where we can test the boundaries of Excel functions.

Custom Sort in List.Sort and Custom Comparison Criteria in List.Max

Custom Sort in List.Sort to Sort Nested Lists - Power Query:

Our dataset consists of a list within list structure. Each of these inner lists includes three numbers.

Our goal is to sort the main list according to the sum of the numbers in each inner list.

While we could apply List.Sum within List.Transform followed by sorting, this method would result in the loss of both the structure and the values in the inner lists.

To sort a nested list based on the sum of its inner lists while preserving the overall structure and values, we can utilize the List.Sort function.

= List.Sort(Source, {each List.Sum(_),Order.Descending})


Custom Comparison Criteria in List.Max:


We aim to extract a list that contains the maximum value determined by the sum of the numbers within each inner list, utilizing the same nested list dataset.

To achieve this, we can apply the Comparison Criteria argument in the List.Max function to compute the sum of each inner list and extract the one with the highest value.

= List.Max(Source,null, (x,y) => Value.Compare(List.Sum(x), List.Sum(y)))



Commentaires


  • Facebook
  • Twitter
  • LinkedIn

©2022 by Excel with Excel. Proudly created with Wix.com

bottom of page