cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
primolee Regular Visitor
Regular Visitor

Calling a function and function name is in a data row

Hello everyone,

 

I would like to add a new column using pre-made functions with 2 parameters, and the name of functions are in a column.

 

I used Expression.Evaluate + Record.Combine to accomplish so previously.  However, as #shared only works in Power Query but does not work in Power BI, I need other solutions.

 

Could someone please help me with the correct M expression?

 

Thank you so much for your time and help.

Expression.jpg

1 REPLY 1
primolee Regular Visitor
Regular Visitor

Re: Calling a function and function name is in a data row

Just found others' solution.

 

First, turn the functions that I need into a list then use that list.

 

var_Shared = #shared,
ProcessorFunctionNames = List.Select(Record.FieldNames(var_Shared),each Text.EndsWith(_,"Processor")),
Result = List.Transform(ProcessorFunctionNames, each _ & " = " & _ & ","),

 

Original expression:

Expression.Evaluate( _[Processor] & "( _[Folder Path] & _[Name] , _[Publisher] )", Record.Combine({[_=_],#shared}))

 

New expression:

Expression.Evaluate( _[Processor] & "( _[Folder Path] & _[Name] , _[Publisher] )", Record.Combine({[_=_],Result}))

 

However, I am getting an expression error "Cannot turn values of List type into Record type.

temp.jpg

 

Could anyone please help me with this line?  Thank you very much.

Helpful resources

Announcements
New Ranks and Rank Icons in 2020

New Ranks and Rank Icons in 2020

Read the announcement for more information!

New Kudos Given Badges Coming

New Kudos Given Badges Coming

We're rolling out new Kudos Given badges. Find out how many Kudos you've given.

November 2019 Community Highlights

November 2019 Community Highlights

Get an overview of the events and great community content from November.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)