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
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
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 Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

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.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Top Kudoed Authors
Users Online
Currently online: 362 members 3,435 guests
Please welcome our newest community members: