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

The Fabric community is now in read-only for platform upgrade. Learn more

Reply
golbarg
Frequent Visitor

Issues invoking custom function from another

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!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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])))

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

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.

Anonymous
Not applicable

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

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.