Skip to content

Instantly share code, notes, and snippets.

@ncalm
Created November 22, 2023 18:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncalm/f32c1a16f531e4875d30c9475677fa07 to your computer and use it in GitHub Desktop.
Save ncalm/f32c1a16f531e4875d30c9475677fa07 to your computer and use it in GitHub Desktop.
This Excel LAMBDA gist replicates PERCENTOF functionality for other aggregates
/*
Replicating PERCENTOF for non-SUM aggregates
Usage:
For percent of max:
=PERCENTOFFN(MAXL)(data_subset,data_all)
In GROUPBY function argument:
PERCENTOFFN(MAXL)
Note: At this time, this doesn't work:
=PERCENTOFFN(MAX)(data_subset,data_all)
In GROUPBY function argument:
PERCENTOFFN(MAX)
*/
MAXL = LAMBDA(a,MAX(a));
SUML = LAMBDA(a,SUM(a));
AVGL = LAMBDA(a,AVERAGE(a));
MINL = LAMBDA(a, MIN(a));
// etc
PERCENTOFFN = LAMBDA(function,
LAMBDA(data_subset, data_all,
function(data_subset) / function(data_all)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment