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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
nok
Advocate II
Advocate II

Get attachment link from SP List Attachment column

Hello!

I have a SharePoint list that has files attached in the Attachments column.
img_pbi.png

I want to create a visual table in my Power BI that shows the attachment link for each item in this list, so that the user can click on the link and be redirected to the file if they want to download it. How can I get the attachment link from a SharePoint list and use it in Power BI?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @nok , hello MattiaFratello, thank you for your prompt reply!

 

Create a new blank query and paste the following M code to meet your requirement:

let
    SharePointSiteURL = "YourSharePointSiteUrl",

    SharePointTenant="https://Yourtenantname.sharepoint.com",
    
    API_URL = SharePointSiteURL & "/_api/web/lists/getbytitle('YourListName')/items?$expand=AttachmentFiles",
    
    Source = Json.Document(Web.Contents(API_URL, [Headers=[#"Accept"="application/json;odata=nometadata"]])),
    
    ListItems = Source[value],
    
    ExpandedItems = Table.ExpandRecordColumn(Table.FromList(ListItems, Splitter.SplitByNothing()), "Column1", {"ID", "Title", "AttachmentFiles"}),
    
    ExpandedAttachments = Table.ExpandListColumn(ExpandedItems, "AttachmentFiles"),
    
    AttachmentUrls = Table.ExpandRecordColumn(ExpandedAttachments, "AttachmentFiles", {"ServerRelativeUrl"}),
    
    FinalTable = Table.AddColumn(AttachmentUrls, "AttachmentLink", each SharePointTenant & [ServerRelativeUrl], type text),

    ResultTable = Table.SelectColumns(FinalTable, {"ID", "Title", "AttachmentLink"})
    
in
    ResultTable

Remember to cahnge the siteurltenantname, and listname to your specific values

After that, format the text in the column as a web URL:

vyajiewanmsft_0-1738567176640.png

My sample test for your reference:

vyajiewanmsft_1-1738567262730.png

Best regards,

Joyce

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
Anonymous
Not applicable

Hi @nok , hello MattiaFratello, thank you for your prompt reply!

 

Create a new blank query and paste the following M code to meet your requirement:

let
    SharePointSiteURL = "YourSharePointSiteUrl",

    SharePointTenant="https://Yourtenantname.sharepoint.com",
    
    API_URL = SharePointSiteURL & "/_api/web/lists/getbytitle('YourListName')/items?$expand=AttachmentFiles",
    
    Source = Json.Document(Web.Contents(API_URL, [Headers=[#"Accept"="application/json;odata=nometadata"]])),
    
    ListItems = Source[value],
    
    ExpandedItems = Table.ExpandRecordColumn(Table.FromList(ListItems, Splitter.SplitByNothing()), "Column1", {"ID", "Title", "AttachmentFiles"}),
    
    ExpandedAttachments = Table.ExpandListColumn(ExpandedItems, "AttachmentFiles"),
    
    AttachmentUrls = Table.ExpandRecordColumn(ExpandedAttachments, "AttachmentFiles", {"ServerRelativeUrl"}),
    
    FinalTable = Table.AddColumn(AttachmentUrls, "AttachmentLink", each SharePointTenant & [ServerRelativeUrl], type text),

    ResultTable = Table.SelectColumns(FinalTable, {"ID", "Title", "AttachmentLink"})
    
in
    ResultTable

Remember to cahnge the siteurltenantname, and listname to your specific values

After that, format the text in the column as a web URL:

vyajiewanmsft_0-1738567176640.png

My sample test for your reference:

vyajiewanmsft_1-1738567262730.png

Best regards,

Joyce

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

MattiaFratello
Super User
Super User

Hi @nok, you can connect to your sharepoint list using 
New Source -> Others -> SharePoint Online List
Use the truncated URL of your SP https://yoursharepointname.sharepoint.com/sites/xxx

 

Click then on Table under the column Items for the correct SP list you want to import

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.