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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
paddyg95
New Member

Retrieving data from file uploaded to SharePoint list

Hi,

I have created a SharePoint list where users will upload an Excel file every time they make an entry to the list. I am using a list rather than just a file folder just for greater control of the meta data.

I would like to retrieve the data from the uploaded Excel files in the list in the same way that I would retrieve the data from a file folder. Is this possible with Power Query? When I query the SharePoint list there isn't a 'content' column in the same way that you would have with a SharePoint file folder.

Any help would be much appreciated

Thanks,

Paddy

1 ACCEPTED SOLUTION

Hi Paddy,

 

Try this:

1) Connect to your SP list using the SharePoint Online List connector in Power Query and choose the 1.0 Implementation. This is important as the 2.0 version won't give you the [AttachmentFiles] column that you need.

2) Expand the [AttachmentFiles] column files selecting the [ServerRelativeUrl] column to expand.

2.5) Important - at this point, filter the list to ensure only attachments that have the same data structure remain.

3) Create a new custom column like this:

"https://yourcompany.sharepoint.com" & [ServerRelativeUrl]
//Obvs change "yourcompany" to whatever your actual URL is

 

4) Copy one of the complete URLs from your new column, open the Web connector, and connect to this URL. Complete any transformations you want to do on all of the attachments in this query.

5) Open Advanced Editor for this Web query and copy ALL of the M code from there. Go back to your SharePoint query and add another custom column.

6) Paste the M code into the formula window for this custom column, but change the URL to reference your full URL column instead, like this:

BA_Pete_0-1710172092845.png

 

Now, when you click OK, you should get a column with nested tables that contain each of your transformed attachments that you can expand to append them all together:

BA_Pete_2-1710172279511.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

4 REPLIES 4
BA_Pete
Super User
Super User

Hi @paddyg95 ,

 

Going to need a bit more info here:

- Are you adding the actual files (attaching/embedding) to the SP list, or just URLs that point to the files?

- If you're adding/attaching/embedding the actual files, what column/data type are you using in the SP list to enable this?

- If you're only concerned with additional metadata, might it be feasible to use Power Automate to detect file changes in a folder and write your metadata to a SP list instead?

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Hi Pete,

thank you for the reply, much appreciated.

I am attaching the actual files and would like to get the data from those files, so below is a screenshot of how that looks in the list. For context, the SP list is for users to upload forecast files and I would like to get both the metadata from the list (e.g. the forecast date entered by the user on the list row), as well as the file contents from the uploaded file, but it's the file contents I'm struggling with.

Many thanks,

Paddy


SP List forecast file.png

Hi Paddy,

 

Try this:

1) Connect to your SP list using the SharePoint Online List connector in Power Query and choose the 1.0 Implementation. This is important as the 2.0 version won't give you the [AttachmentFiles] column that you need.

2) Expand the [AttachmentFiles] column files selecting the [ServerRelativeUrl] column to expand.

2.5) Important - at this point, filter the list to ensure only attachments that have the same data structure remain.

3) Create a new custom column like this:

"https://yourcompany.sharepoint.com" & [ServerRelativeUrl]
//Obvs change "yourcompany" to whatever your actual URL is

 

4) Copy one of the complete URLs from your new column, open the Web connector, and connect to this URL. Complete any transformations you want to do on all of the attachments in this query.

5) Open Advanced Editor for this Web query and copy ALL of the M code from there. Go back to your SharePoint query and add another custom column.

6) Paste the M code into the formula window for this custom column, but change the URL to reference your full URL column instead, like this:

BA_Pete_0-1710172092845.png

 

Now, when you click OK, you should get a column with nested tables that contain each of your transformed attachments that you can expand to append them all together:

BA_Pete_2-1710172279511.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Brilliant, thanks very much Pete. Works perfectly and easy to follow your instructions. 
Paddy

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors