Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi all,
I don't seem to find correct syntax to invoke my custom function from a query. I have this function called xReplace that changes a lot of strings into something else. The function has no parameters - I simply need to place (get executed) instructions of the function so that I do not have to type them again in every query.
(mySource) =>
let
#"Replaced Value" = Table.ReplaceValue(mySource,"ABC","123",Replacer.ReplaceText,{"ProductID"}),
#"Replaced Value2" = Table.ReplaceValue(#"Replaced Value","DDD","456",Replacer.ReplaceText,{"ProductID"})
in
#"Replaced Value2"I am trying to do it like this, but Power BI complains, that it cannot convert a value of type Table to type List.
let
Source = ....
my = Function.Invoke(xReplace,#"Renamed Columns")
in
myAny ideas what am I doing wrong here?
Solved! Go to Solution.
Function.Invoke expects a list as second argument.
It should be OK if you put the argument between curly brackets.
let
Source = ....
my = Function.Invoke(xReplace,{#"Renamed Columns"})
in
my
Otherwise you might consider not to use Function.Invoke and just call the function directly.
I don't think Function.Invoke has any added value in this case.
Function.Invoke expects a list as second argument.
It should be OK if you put the argument between curly brackets.
let
Source = ....
my = Function.Invoke(xReplace,{#"Renamed Columns"})
in
my
Otherwise you might consider not to use Function.Invoke and just call the function directly.
I don't think Function.Invoke has any added value in this case.
Great, thanks! How do I call function directly? I thought I should use Invoke?
By the way, for multiple replacements you might consider using List.Accumulate.
You can find an example in my answer on this post on StackOverflow.
@MarcelBeug wrote:By the way, for multiple replacements you might consider using List.Accumulate.
I understand this is to change individual characters. I need to change the whole phrases.
In the example I may have used List.Accumulate to replace single characters.
In the video below, you can find more information about List.Accumulate with an explanation on how to change substrings starting at at 3:23.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 46 | |
| 43 | |
| 39 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 68 | |
| 67 | |
| 31 | |
| 27 | |
| 24 |