cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
thomasreick
Resolver I
Resolver I

Question: Does "read N files from Sharepoint-folder" work for N=1?

Hello there,

I want to load one file only(!) using the Read-(and combine)-Multiple-Files-From-Sharepoint-Folder"-Functionality.

It seems that tis does not work for N=1, only for N>1.

Can you please comment on this?

 

Reason why I am asking:

on an unregularily base I receive 1 CSV-File that needs to be integrated into reporting.

Unfortunately the file name contains a date, which needs to be handled with a workaround before loading to SP-Folder.

I would like to get rid of this workaround and tried the Read-Multiple-Approach.

Do you have any idea(s)?

 

thx in advance

Thomas

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

Hi @thomasreick ,

 

The "Read Multiple Files from SharePoint Folder" functionality is designed to read multiple files from a folder, and it may not work for a single file. However, you can still use the SharePoint connector to read a single file from a folder. Here is an example of how to read a single file from a SharePoint folder using the SharePoint connector:

 

let
    Source = SharePoint.Files("https://yoursharepointsite.sharepoint.com/sites/yourfolder/"),
    #"Filtered Rows" = Table.SelectRows(Source, each ([Name] = "yourfile.csv")),
    #"Content" = #"Filtered Rows"{0}[Content]
in
    #"Content"

 

Replace "https://yoursharepointsite.sharepoint.com/sites/yourfolder/" with the URL of your SharePoint site and folder, and replace "yourfile.csv" with the name of your file. This code will read the content of the file into a table.

 

Hope it helps.

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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-stephen-msft
Community Support
Community Support

Hi @thomasreick ,

 

The "Read Multiple Files from SharePoint Folder" functionality is designed to read multiple files from a folder, and it may not work for a single file. However, you can still use the SharePoint connector to read a single file from a folder. Here is an example of how to read a single file from a SharePoint folder using the SharePoint connector:

 

let
    Source = SharePoint.Files("https://yoursharepointsite.sharepoint.com/sites/yourfolder/"),
    #"Filtered Rows" = Table.SelectRows(Source, each ([Name] = "yourfile.csv")),
    #"Content" = #"Filtered Rows"{0}[Content]
in
    #"Content"

 

Replace "https://yoursharepointsite.sharepoint.com/sites/yourfolder/" with the URL of your SharePoint site and folder, and replace "yourfile.csv" with the name of your file. This code will read the content of the file into a table.

 

Hope it helps.

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

ppm1
Solution Sage
Solution Sage

You could parse the date out of the filename to create a date column and then you can either sort by that or use the Table.Max function to keep only the latest file. You don't have to use the Combine & Transform functionality on this one.

 

Pat

Microsoft Employee

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors