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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Helper IV
Helper IV

How do I try/resolve in a function data source ?

I have a PowerQuery that has to iterate throught 1,000+ SharePoint sites, and pull some data from a specific list on each site. Now obviously each site, having it's own configuration means there's lots of room for mistakes.

There are four possible outcomes which I am trying to identify:

  1. The list is good, and I can retrieve the MAX of "last Modified date" 
  2. The list does not exist, so I need a label "No list exists"
  3. The list  has no records and is empty, so "Not used"
  4. The list cannot be access due to permission, so "Access Denied" 

So here's what my table of URLs looks like:




Coincidentially it's some of the exmlex2 sites that are the culprits - but there is no predicting whch one will give problems. 

So each site has a list, with a specific name, and that is the list I want to check. 

The list name is "Forecast", obviously on each site each site, the list will have a different GUID, so it has to be done by name. 

What I am trying to achieve is this: 


...... list exists
...... Denied
...... used



So... I need a table of URLs, and a custom function with some error handling. The process must complete, despite all obstacles. 

My biggest problem, is that I cannot make error handling work in a custom function, when the error is the datasource. 




    Source = ...,
    #"Added Custom" = Table.AddColumn(#"Source", "Forecast", each 
            "Something else unforseen" 
    #"Added Custom"




And here is the custom fuction interrogateList()





    Source = (URL as any) => 
       Source2  = try 
                      SharePoint.Tables(URL, [ApiVersion = 15])
                      # if not empty, try get the last modified date
                       "Access Denied"



The script runs fine but a "problem url" does not get trapped - it just bombs with "The credentials provided are invalid" - so this error handling is ineffective.


Another perspective: It's not an HTTP error - SharePoint is serving up the response just fine. 

It's an authentication issue. 

Community Support
Community Support

Hi @Netrelemo,

You can create a table with a list of these source SharePoint URLs, then you can add a custom column with try/otherwise structure and data connector to invoke and catch the result of these links.


Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

I know. That's exactly what I am doing now. But it doesn't work. 

Hi @Netrelemo,

Can you please share some more detail about your sceniaro? They should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  


Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

I've tried to reword the problem with more detail

Helpful resources

Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City


Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors