Forum Discussion

po's avatar
po
Post Prodigy
6 years ago
Solved

Connecting to sharepoint data source

Hi,

 

Have a working report which uses sharepoint as a source but to get this to work I had to connect to the all documents on the site and filter them and select file etc.

resulting power query below.

 

let
Source = SharePoint.Files("https://<company_name>.sharepoint.com/sites/BI/", [ApiVersion = 15]),
#"Filtered Rows" = Table.SelectRows(Source, each ([Extension] = ".csv")),
#"workspaces csv_https://menziesdistribution sharepoint com/sites/BI/Shared Documents/Power BI/Workspace Inventory/" = #"Filtered Rows"{[Name="workspaces.csv",#"Folder Path"="https://menziesdistribution.sharepoint.com/sites/BI/Shared Documents/Power BI/Workspace Inventory/"]}[Content],
#"Imported CSV" = Csv.Document(#"workspaces csv_https://menziesdistribution sharepoint com/sites/BI/Shared Documents/Power BI/Workspace Inventory/",[Delimiter=",", Columns=7, Encoding=1252, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(#"Imported CSV", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Id", type text}, {"Name", type text}, {"Type", type text}, {"State", type text}, {"IsReadOnly", type logical}, {"IsOrphaned", type logical}, {"CapacityId", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Name", "WorkspaceName"}})
in
#"Renamed Columns"

 

Just wondering if easier better way of doing this e.g. tried source below but doesn't work.

 

Is there a quciker way to do this in tersm of code.  I'm just thinking whilst not that many documents on site if this grows speed will slow down a little.

 

https://<company_name>.sharepoint.com/sites/BI/Shared Documents/Power BI/Workspace Inventory/workspaces.csv

 

 

Thanks

  • Hi po ,

    If you want to get one specific file in SharePoint folder, I would suggest you to use Web connector instead of SharePoint connector to save some time.

    URL will be like:

    https://xxxx.sharepoint.com/sites/xxxx/Shared Documents/<file name>

     

    Best Regards,
    Yingjie Li

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

3 Replies