2nd largest value

fb7894
Posts: 18
Joined: Thu Aug 16, 2018 11:18 pm

2nd largest value

Postby fb7894 » Sat May 04, 2019 5:24 am

List.Max(step[column]) will find the largest value in a column.

How can I find the 2nd largest value?

PhilC
Posts: 274
Joined: Tue Sep 09, 2014 8:13 am

Re: 2nd largest value

Postby PhilC » Mon May 06, 2019 1:20 pm

Maybe have a look at List.RemoveMatchingItems and remove the max value from the list and then recheck the list.

Does not seem efficient, but might keep you moving until someone else provides a more elegant solution.

Cheers

fb7894
Posts: 18
Joined: Thu Aug 16, 2018 11:18 pm

Re: 2nd largest value

Postby fb7894 » Mon May 06, 2019 11:15 pm

Thanks Phil. Another solution (I 'invented' :) ) was to sort the list of dates and return the 2nd value.

Once again, this works but does not seem efficient.

List.Sort(PreviousStep[Date],Order.Descending){1}

Rudi
Posts: 16
Joined: Fri Sep 01, 2017 4:33 pm

Re: 2nd largest value

Postby Rudi » Wed May 15, 2019 4:20 pm

Another option:

= List.Skip(List.MaxN(Source, 2),1)


Return to “Power Query”

Who is online

Users browsing this forum: No registered users and 2 guests

cron