Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to connect a specific Sharepoint folder?

Hello!

 

I am having issues to connect a specific Sharepoint folder to PowerBI. I get a 404 error when I enter the full Sharepoint folder url.

 

Instead, what I can only do, is to enter the Sharepoint root url as a Web Source and then I have to filter through all the files in the Sharepoint site which is not efficient.

 

Is there a workaround for that?

 

Thanks!

  • Hi Anonymous,

     

    You could go directly to a file with...

    Web.Contents("https://yourdomain.sharepoint.com/sites/yoursite/Shared Documents/yourfolderpath/file.extension")

     

    Typically what I do is have two parameters setup, a pSite and pFolder.

     

    The first query I keep as a staging query to pull back all of the required files to be reused in other queries.

    It may seem inefficient but it is not pulling back all of the site files, only the metadata properties.

    // pSite
    "https://yourdomain.sharepoint.com/sites/yoursite/" meta [IsParameterQuery=true, Type="Text", IsParameterQueryRequired=true]
    
    // pFolder
    "yourfolderpath/" meta [IsParameterQuery=true, Type="Text", IsParameterQueryRequired=true]
    
    // Query1
    let
        Source = SharePoint.Files(pSite, [ApiVersion = 15]),
        #"Filtered Rows" = Table.SelectRows(Source, each ([Folder Path] = pSite & pFolder))
    in
        #"Filtered Rows"
    
    

     

    Hope this helps.

3 Replies

  • KNP's avatar
    KNP
    Icon for Super User rankSuper User

    Hi Anonymous,

     

    You could go directly to a file with...

    Web.Contents("https://yourdomain.sharepoint.com/sites/yoursite/Shared Documents/yourfolderpath/file.extension")

     

    Typically what I do is have two parameters setup, a pSite and pFolder.

     

    The first query I keep as a staging query to pull back all of the required files to be reused in other queries.

    It may seem inefficient but it is not pulling back all of the site files, only the metadata properties.

    // pSite
    "https://yourdomain.sharepoint.com/sites/yoursite/" meta [IsParameterQuery=true, Type="Text", IsParameterQueryRequired=true]
    
    // pFolder
    "yourfolderpath/" meta [IsParameterQuery=true, Type="Text", IsParameterQueryRequired=true]
    
    // Query1
    let
        Source = SharePoint.Files(pSite, [ApiVersion = 15]),
        #"Filtered Rows" = Table.SelectRows(Source, each ([Folder Path] = pSite & pFolder))
    in
        #"Filtered Rows"
    
    

     

    Hope this helps.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous,

    Did these suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements.

    If these also don't help, please share more detailed information to help us clarify your scenario to test.

    How to Get Your Question Answered Quickly 

    Regards,

    Xiaoxin Sheng