Forum Discussion
Change Data Source from offline excel to SharePoint
- 4 years ago
If you go into 'Transform data' and look in the advanced editor for your query it will look something like this for local files...
// Local let Source = Excel.Workbook(File.Contents("D:\Downloads\book.xlsx"), null, true), Sheet1_Sheet = Source{[Item = "Sheet1", Kind = "Sheet"]}[Data], #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars = true]), #"Changed Type" = Table.TransformColumnTypes( #"Promoted Headers", {{"a", Int64.Type}, {"b", Int64.Type}, {"c", Int64.Type}} ) in #"Changed Type"What you need for SharePoint is something that looks like...
// SharePoint let Source = SharePoint.Files( "https://youdomain.sharepoint.com/sites/yoursite", [ApiVersion = 15] ), #"Filtered Rows" = Table.SelectRows(Source, each ([Name] = "book.xlsx")), ExcelFile = #"Filtered Rows" { [ Name = "book.xlsx", #"Folder Path" = "https://yourdomain.sharepoint.com/sites/yoursite/Shared Documents/Data/" ] } [Content], #"Imported Excel Workbook" = Excel.Workbook(ExcelFile), Sheet1_Sheet = #"Imported Excel Workbook"{[Item = "Sheet1", Kind = "Sheet"]}[Data], #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars = true]), #"Changed Type" = Table.TransformColumnTypes( #"Promoted Headers", {{"a", Int64.Type}, {"b", Int64.Type}, {"c", Int64.Type}} ) in #"Changed Type"Essentially, you need to replace the top row of the local one with the top couple of rows of the SharePoint one. Obviously that varies depending on the complexity of your setup.
Hope that helps.
Anonymous So, typically the way that you do this is to create a new query that just connects to your new data source. Open this query in Advanced Editor and copy the Source and possibly Navigation lines at the top of the query. Now open your old query in Advanced Editor and replace the same lines with the copied lines.
Hi Greg,
Thank you for coming back to me! Apologies, as a new user you may need to break this down for me a little more. How would I connect the SharePoint file to the PowerBI?