fncLarge
Function: Large
Name: fncLarge()
Use:
Use when Excel's LARGE() function is needed in PowerQuery
Description:
This mimics Excel's LARGE(Array, n) function.
Parameters
This function has two parameters: ListOfValues and nthPosition. ListOfValues is an M list containing numbers to compare. nthPosition is the position of the number sought were 1=Largest.
Example:
let
RowCount = fncLookup("tblMP", "Periods"),
DynTbl = fncCrtTblRows(RowCount, "Prd")
in
DynTbl
Code:
/* Description:This is the equivalent of =LARGE(Array, N)
Inputs: ListOfValues: A list of values to compare
nthPosition: The position of the number sought were 1=Largest
Outputs: Value: nth largest number in a list
Reference: https://www.reddit.com/r/PowerBI/comments/ivffei/how_to_get_nth_largest_value_power_query/
Date Ini Description
01/01/2020 ubbm Original Development
*/
(listOfValues as list, nthPosition as number) as number =>
let
Result = List.Sort(listOfValues, Order.Descending){nthPosition-1}
in
Result