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

Highlighted
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 Ranks and Rank Icons in 2020

New Ranks and Rank Icons in 2020

Read the announcement for more information!

New Kudos Given Badges Coming

New Kudos Given Badges Coming

We're rolling out new Kudos Given badges. Find out how many Kudos you've given.

November 2019 Community Highlights

November 2019 Community Highlights

Get an overview of the events and great community content from November.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)