cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
felipevaz Frequent Visitor
Frequent Visitor

Importing a table using the location provided by CELL

Hi,

 

Please, Im working on a "File.xls" from a folder and transform it on "Final Results".

 

Every month I work on new data and the patterns are the same, only the location of my "File.xls" and "Final Results" changes.

 

Into my "Final Results" has table named ""Location" with function CELL, that gives me the address from my current file after apply LEFT and SEARCH, like this

 

VALUE = LEFT(CELL("filename");SEARCH("[Ser";CELL("filename"))-1)

 

I add to this function a &"File.xls" concatenating with the address, like this:

 

VALUE = LEFT(CELL("filename");SEARCH("[Ser";CELL("filename"))-1)&"File.xls"

 

FINAL VALUE = C:\Users\felipe.vaz\FolderJan\File.xls

 

Every month I download a new "File.xls" again and copy and paste that "Final Results" to a new folder (FolderFeb) and it gives me the position where the new "File.xls" is.

 

I want to use the FINAL VALUE to open the new File.xls every month. But I do know how to transform the final value to use into the Excel.Workbook()

 

Ive tried

 

= Excel.Workbook(File.Contents(Table.FromRecords(Location())), null, true) tells me that unable to convert...

 

Any idea?

 

Files here

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Stachu Super Contributor
Super Contributor

Re: Importing a table using the location provided by CELL

First of all you need to have a location of the file as a string in PowerQuery

Create a new query (e.g. named 'FilePath'), with syntax like this (adjust the names accordingly):

let
    Source = Excel.CurrentWorkbook(){[Name="Location"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", type text}}),
    Value = #"Changed Type"{0}[Value]
in
    Value

Disable the load for 'FilePath'

 

then in the query where you actually load the data use this:

=Excel.Workbook(File.Contents(FilePath), null, true)

where FilePath is the name of the query you created earlier

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

2 REPLIES 2
Highlighted
Stachu Super Contributor
Super Contributor

Re: Importing a table using the location provided by CELL

First of all you need to have a location of the file as a string in PowerQuery

Create a new query (e.g. named 'FilePath'), with syntax like this (adjust the names accordingly):

let
    Source = Excel.CurrentWorkbook(){[Name="Location"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", type text}}),
    Value = #"Changed Type"{0}[Value]
in
    Value

Disable the load for 'FilePath'

 

then in the query where you actually load the data use this:

=Excel.Workbook(File.Contents(FilePath), null, true)

where FilePath is the name of the query you created earlier

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

felipevaz Frequent Visitor
Frequent Visitor

Re: Importing a table using the location provided by CELL

WOW

 

Thank you! Works perfectly and I learned a lot today. Cheers!

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

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

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors (Last 30 Days)