cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
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
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
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Top Kudoed Authors
Users Online
Currently online: 268 members 2,700 guests
Please welcome our newest community members: