Forum Discussion
Calling a function and function name is in a data row
- 6 years ago
I think I understand what your trying to do now... Don't use Expression.Evaluate, it will just make your life harder. Instead use something like:
Record.Field(Output, [Processor])([Folder Path] & [Name], [Publisher]) - 6 years ago
Oh I see what is missing...
Change:
GoogleGSMDailyProcessor = (fileName as text, publisherName as text) => GoogleGSMDailyProcessor,to
GoogleGSMDailyProcessor = (fileName as text, publisherName as text) => GoogleGSMDailyProcessor(fileName, publisherName),Also, if you hit the firewall issue in the online service, go to edit credentialls (for the dataset object, not the report itself) and set "Privacy level setting for this data source" to None
Hi primolee ,
Icey is right on #2, this is for when you need referencing to a current row. My example would look something like:
let
var_Shared = #shared,
ProcessorFunctionNames = List.Select(Record.FieldNames(var_Shared),each Text.EndsWith(_,"Contains")),
Result = Record.SelectFields(var_Shared, ProcessorFunctionNames),
Output = Expression.Evaluate("_[Function]", Record.Combine({[_=_], Result})
in
Output
In your post, you did not add [_=_] to the list of references. This should work:
#"Invoked Custom Function" = Table.AddColumn(#"Check If Publisher Exists", "Processed Tables", each Expression.Evaluate( _[Processor] & "( _[Folder Path] & _[Name] , _[Publisher] )", [_=_, GoogleGSMDailyProcessor=GoogleGSMDailyProcessor,GoogleGSMHourProcessor=GoogleGSMHourProcessor,GoogleGDNDailyProcessor=GoogleGDNDailyProcessor,GoogleGDNAdGroupProcessor=GoogleGDNAdGroupProcessor,GoogleGDNSizeProcessor=GoogleGDNSizeProcessor])),
Kind regards,
JB
Hello jborro,
I added _=_ in the beginning of the square bracket, but same error still occurs: Step #"Invoked Custom Function" is referring to other query or step, therefore cannot directly access data source.
Any more advice?
Moreover, it will be very troublesome if number of my custom functions keeps on growing. Is there any way of making a dynamic record of my functions easier without using #shared? I can manually maintain a list of function names somewhere such as excel.
I am so sorry for asking so much, greatly appreciated. m(_ _)m
- Anonymous6 years agoNot applicableHi,
This is a commonly known issue. Usually, it can be cured by brunching you code. Right-click on the step in the editor and select Extract previous. In you scenario you may need to brunch from a couple of steps before #Invoke. At the point where you define the var_Shared. The main idea is to separate the source of external data from processing with internal data.
As to the list in Excel - this is a good idea. But just as simple you can create a table directly in PBI vis Enter Data. If you keep your functions separately - you always can count-reconcile it.
Another alternative is defining a single function which is called in the main code. You pass the actual name to this function and it decides through if-then or table-filter which function to call. In this case evaluation o ly need to know the name-reference to this wrapper function. It does not need to know that other function even exist.
Kind regards
JB- primolee6 years agoHelper V
Hello jborro,
I just did what you said, Extract Previous at "var_Shared = #shared" step. However, same error still occurs at #Invoke step.
Formula.Firewall: Query 'GenerateOutput' (step 'Invoked Custom Function') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.I defined var_Shared in the very beginning of my advance editor, so when I did extract previous, new query is very short. And my #Invoke step is exactly the same as what you wrote previously.
I just added a table via Enter Data. And I want to manually generate a record like the screenshot below. Is there a way to turn this table into such record? Screenshot is done with #shared, and I am trying to avoid using #shared.
Image 1, table I manually added:
Image 2, hoping to turn the above table to this...
I think there is something to do with name=name, but I can't figure out where to put it... (T_T)
Thank you so much in advance.
- Anonymous6 years agoNot applicableHi,
Sorry, I think, this may be the case where you can only sort it from your end :(.
Do you want to share the entire code you have - remove all sensitive data like url or username and/or send me in private.
I will see if I can suggest anything.
Unfortunately I do nor know any simple solution to your second question- re function table - but I will send you a code which I use in similar circumstances.
Kind regards
JB