cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Jdeem58 Regular Visitor
Regular Visitor

Retain folder or file information when expanding Excel data from Sharepoint

Hi,

I have been searching for an effective solution to retain folder or file information when navigating down to sheet level.

 

I have seen a number of similar posts, including this from Brian M however couldn't really understand it.

https://community.powerbi.com/t5/Desktop/Retain-file-name-column-when-using-Folder-as-a-data-source-...

 

I have found a workaround/ what I think is a clumsy solution however think there must be a more effective way of achieving.

 

My M code is as follows:

let
Source = SharePoint.Files("https://location.sharepoint.com/sites/sharepointname", [ApiVersion = 15]),
#"Filtered Rows" = Table.SelectRows(Source, each ([Name] = "filename.xlsm")),
#"Added Custom" = Table.AddColumn(#"Filtered Rows", "Sheet name", each Excel.Workbook([Content])),
#"Expanded Sheet name" = Table.ExpandTableColumn(#"Added Custom", "Sheet name", {"Name", "Data"}, {"Sheet name.Name", "Sheet name.Data"}),
#"Filtered Rows1" = Table.SelectRows(#"Expanded Sheet name", each ([Sheet name.Name] = "Actuals Feed ADS" or [Sheet name.Name] = "Actuals Feed Comm" or [Sheet name.Name] = "Actuals Feed FS" or [Sheet name.Name] = "Actuals Feed Gov")),
#"Expanded Sheet name.Data" = Table.ExpandTableColumn(#"Filtered Rows1", "Sheet name.Data", {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10", "Column11", "Column12"}, {"Sheet name.Data.Column1", "Sheet name.Data.Column2", "Sheet name.Data.Column3", "Sheet name.Data.Column4", "Sheet name.Data.Column5", "Sheet name.Data.Column6", "Sheet name.Data.Column7", "Sheet name.Data.Column8", "Sheet name.Data.Column9", "Sheet name.Data.Column10", "Sheet name.Data.Column11", "Sheet name.Data.Column12"})
in
#"Expanded Sheet name.Data"

 

My reasoning follows:

1 - locate file of interest in sharepoint

2 - create a custom column to expand sheet information

3 - expand 2 headers 'name' and 'data'

4 - filter sheet name to those desired for further manipulation

5 - expand sheetname.Data to access row information for all sheets selected

 

 

I would be really interested to hear your thoughts on this and where this could be improved.

 

 

Thanks,

J  

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft v-kelly-msft
Microsoft

Re: Retain folder or file information when expanding Excel data from Sharepoint

Hi @Jdeem58

 

Sorry but you have done the best and there's no better choices.

 

 
Best Regards,
Kelly

View solution in original post

2 REPLIES 2
Microsoft v-kelly-msft
Microsoft

Re: Retain folder or file information when expanding Excel data from Sharepoint

Hi @Jdeem58

 

Sorry but you have done the best and there's no better choices.

 

 
Best Regards,
Kelly

View solution in original post

Jdeem58 Regular Visitor
Regular Visitor

Re: Retain folder or file information when expanding Excel data from Sharepoint

Well that's great then! 🙂

thanks for letting me know

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors