This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowThe Fabric community is upgrading! Read all of the details including the timeline and what you can expect. Learn more
Hello,
I'm having trouble finding what's wrong when invoking a custom function from another.
Consider:
/* getTimeEntryPage(updateFrom, page) */
(updateFrom as text, page as text) =>
let
...
in
...
This works as expected whan manually invoked with, for example: getTimeEntryPage("2021-03-24", "1").
Now, I also have this:
/* getTimeEntriesFromDate(updateFrom) */
(updateFrom as text) =>
let
Source = Json.Document(Web.Contents(/*This query works*/)),
List = {1..Source[total_pages]},
#"Converted to Table" = Table.FromList(List, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "page"}}),
#"Invoked Custom Function" = Table.AddColumn(#"Renamed Columns", "getTimeEntryPage", each getTimeEntryPage(updateFrom, [page])),
...
in
...
When I call getTimeEntriesFromDate("2021-03-24") manually, I get the following error:
"Unexpected error: Operation is not valid due to the current state of the object."
In the #"Invoked Custom Function" line, the following will work (although will only return a subset of data):
getTimeEntryPage(updateFrom, "1")
In the same line, the following will return the same error as above (expected as 1 is a number, not the expected text type):
getTimeEntryPage(updateFrom, 1)
Since [page] is set to text type, I don't understand why this is not working. Does anyone have an idea?
Note: I've made sure the origin data is clean.
Thanks!
Solved! Go to Solution.
Hi @golbarg
Are you sure it is the issue with [page]? Can you try to wrap Text.From([page]), see how it goes?
#"Invoked Custom Function" = Table.AddColumn(#"Renamed Columns", "getTimeEntryPage", each getTimeEntryPage(updateFrom, Text.From([page])))
Hi @golbarg
Are you sure it is the issue with [page]? Can you try to wrap Text.From([page]), see how it goes?
#"Invoked Custom Function" = Table.AddColumn(#"Renamed Columns", "getTimeEntryPage", each getTimeEntryPage(updateFrom, Text.From([page])))
Hey @Anonymous,
Wow, that was easier than expected, it worked, thanks!
Any idea why I need to convert a text value to text? It feels wrong.
Hi @golbarg
No, it does not seem to be needed to convert a text to text...I tried to replicate your case with a simple custom function and a list of numbers, it worked after the column changed to text, did not occur the issue...maybe you should have a look at your custom function getTimeEntryPage
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
| User | Count |
|---|---|
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |