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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
primolee
Helper V
Helper V

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
Helper V
Helper V

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors