Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Dicken
Post Prodigy
Post Prodigy

Function selection

Hi, 
a while ago i wanted to have way of selecting whihc function to use within a formala; ie sum,  or average; 

i have 2 ways   Expession.Evaluate and  Function.Invoke;   so ; 

select = parameter list  which is a list of 0,1 
let
  Source = #table(
    type table [Item = text, Unit = number], 
    {{"a", 2}, {"b", 3}, {"c", 3}, {"a", 2}, {"c", 2}, {"b", 4}}
  ), 

  flist = {List.Sum, List.Average},

  Custom1 = Table.Group(Source, {"Item"}, {{"N", each Function.Invoke(flist{select}, {[Unit]})}})
in
  Custom1

or 

textselect = parameter list "a", "b" 
let
  Source = #table(
    type table [Item = text, Unit = number],
    {{"a", 2}, {"b", 3}, {"c", 3}, {"a", 2}, {"c", 2}, {"b", 4}}
  ),
  Custom1 = Table.Group(
    Source,
    {"Item"},
    {{"N", each Expression.Evaluate(textselect, [a = List.Sum, b = List.Average])([Unit])}}
  )
in
  Custom1


Just wondered if anyone had other ways of  selectiing functions   or making a type of slicer for pq ? 

Richard. 

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

Make textselect a parameter

 

ThxAlot_0-1776281012776.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

1 REPLY 1
ThxAlot
Super User
Super User

Make textselect a parameter

 

ThxAlot_0-1776281012776.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.