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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Netrelemo
Helper IV
Helper IV

How do I get a single value from a function?

I thought I could just reduce the custom functions results to the bare minimum, but it doesn't work. 

 

 

 

Expression.Error: We cannot convert a value of type Function to type Text.
Details:
    Value=[Function]
    Type=[Type]

 

let

    Source = OData.Feed("https://xxxxxxxxx.sharepoint.com/sites/edison/_api/ProjectData", null, [Implementation="2.0"]),
    Projects_table = Source{[Name="Projects",Signature="table"]}[Data],

    #"Removed Other Columns" = Table.SelectColumns(Projects_table,{"ProjectId", "ProjectIdentifier", "ProjectLastPublishedDate", "ProjectModifiedDate", "ProjectName", "ProjectWorkspaceInternalUrl"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Other Columns",{{"ProjectIdentifier", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([ProjectIdentifier] <> null)),
    #"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"ProjectName", Order.Ascending}}),
    #"Invoked Custom Function" = Table.AddColumn(#"Sorted Rows", "getPHRdataFromSite", each getPHRdataFromSite([ProjectWorkspaceInternalUrl]))
in
    #"Invoked Custom Function"

 

 

 

 

(projectSiteURL as text) as text =>

let
    Source = SharePoint.Tables(projectSiteURL, [Implementation=null, ApiVersion=15]),
    PHRFolder = Source{[Title="ReportArchive"]}[Items],
    #"Removed Other Columns" = Table.SelectColumns(#"PHRFolder",{ "Report Date"}),
    #"Sorted Rows" = Table.Sort(#"Removed Other Columns",{{"Report Date", Order.Ascending}}),
    #"Kept Last Rows" = Table.LastN(#"Sorted Rows", 1),
    Table2Text = Table.ToList(#"Kept Last Rows")


in 
    getPHRdataFromSite

 

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @Netrelemo ,

 

You can try this code for function:

 

let getPHRdataFromSite = (projectSiteURL as text) =>
    let
        Source = SharePoint.Tables(projectSiteURL, [Implementation=null, ApiVersion=15]),
        PHRFolder = Source{[Title="ReportArchive"]}[Items],
        #"Removed Other Columns" = Table.SelectColumns(#"PHRFolder",{ "Report Date"}),
        #"Kept Last Rows" = Table.LastN(#"Removed Other Columns", 1)

    in
        #"Kept Last Rows"
in
getPHRdataFromSite

 

 

And the table query:

 

let

    Source = OData.Feed("https://xxxxxxxxx.sharepoint.com/sites/edison/_api/ProjectData", null, [Implementation="2.0"]),
    Projects_table = Source{[Name="Projects",Signature="table"]}[Data],

    #"Removed Other Columns" = Table.SelectColumns(Projects_table,{"ProjectId", "ProjectIdentifier", "ProjectLastPublishedDate", "ProjectModifiedDate", "ProjectName", "ProjectWorkspaceInternalUrl"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Other Columns",{{"ProjectIdentifier", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([ProjectIdentifier] <> null)),
    #"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"ProjectName", Order.Ascending}}),

    #"Added Custom" = Table.AddColumn(#"Sorted Rows", "getPHRdataFromSite", each function([ProjectWorkspaceInternalUrl])),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "getPHRdataFromSite", {"Report Date"}, {"getPHRdataFromSite.Report Date"})

in
    #"Expanded Custom"

 

 Add invoked column and expand them.

vchenwuzmsft_0-1648111266162.pngvchenwuzmsft_1-1648111294184.png

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-chenwuz-msft
Community Support
Community Support

Hi @Netrelemo ,

 

You can try this code for function:

 

let getPHRdataFromSite = (projectSiteURL as text) =>
    let
        Source = SharePoint.Tables(projectSiteURL, [Implementation=null, ApiVersion=15]),
        PHRFolder = Source{[Title="ReportArchive"]}[Items],
        #"Removed Other Columns" = Table.SelectColumns(#"PHRFolder",{ "Report Date"}),
        #"Kept Last Rows" = Table.LastN(#"Removed Other Columns", 1)

    in
        #"Kept Last Rows"
in
getPHRdataFromSite

 

 

And the table query:

 

let

    Source = OData.Feed("https://xxxxxxxxx.sharepoint.com/sites/edison/_api/ProjectData", null, [Implementation="2.0"]),
    Projects_table = Source{[Name="Projects",Signature="table"]}[Data],

    #"Removed Other Columns" = Table.SelectColumns(Projects_table,{"ProjectId", "ProjectIdentifier", "ProjectLastPublishedDate", "ProjectModifiedDate", "ProjectName", "ProjectWorkspaceInternalUrl"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Other Columns",{{"ProjectIdentifier", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([ProjectIdentifier] <> null)),
    #"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"ProjectName", Order.Ascending}}),

    #"Added Custom" = Table.AddColumn(#"Sorted Rows", "getPHRdataFromSite", each function([ProjectWorkspaceInternalUrl])),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "getPHRdataFromSite", {"Report Date"}, {"getPHRdataFromSite.Report Date"})

in
    #"Expanded Custom"

 

 Add invoked column and expand them.

vchenwuzmsft_0-1648111266162.pngvchenwuzmsft_1-1648111294184.png

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

your function returns

getPHRdataFromSite

which is nowhere to be seen in the above code.  But even if you would return Table2Text it would still be a list, not a scalar value.

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.