Forum

Evaluate string fro...
 
Notifications
Clear all

Evaluate string from named range from Excel

6 Posts
2 Users
0 Reactions
268 Views
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

Hi Guys,

i have cell in Excel where i have named range name : "MyNamedRange". 

In Names manager there is formula , for example "=1 + A2" and result is dynamic. 
It is possible to evaluate witthin PQ string = name of named range? 

Thanks for help,
Jacek

 
Posted : 04/06/2020 4:14 am
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

I am attaching example workbook.

Screenshot_21.png

 

here is a string which PQ should take, and evaluate inside (it is the name of named range in names manager in Excel).

Please help,

Jacek

 
Posted : 04/06/2020 12:31 pm
(@catalinb)
Posts: 1937
Member Admin
 

Hi,

You can take a value from an excel named range just like you do for any table:

= Excel.CurrentWorkbook(){[Name="namedrng"]}[Content]

A table import looks like: = Excel.CurrentWorkbook(){[Name="Table1Name"]}[Content]

If the range is a one cell only, use: = Excel.CurrentWorkbook(){[Name="namedrng"]}[Content]{0}[Column1]

{0} refers to first cell in the named range.

 
Posted : 05/06/2020 5:43 am
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

Hi Catalin,

1.why to use table to import named range? Can not just directly import it? 

2. Assume that "namedrng" is is not named range in cell. It is just a string. It is string which is refering to the same named namerange in names manager so it is evalualting each time when you are refering to it. 
Can you evaluate name range in PQ itself or it has to be evaluated first in cell and PQ will take only value from it? 

Best,
Jacek

 
Posted : 05/06/2020 10:09 am
(@catalinb)
Posts: 1937
Member Admin
 

You said: i have cell in Excel where i have named range name : "MyNamedRange". 

Now you're saying that it's not a named range, it is a defined name only? There is a difference between them.

Power query cannot read defined names that don't refer to a range.

You mentioned that you have a named cell, so I provided the solution for reading named ranges:

= Excel.CurrentWorkbook(){[Name="namedrange"]}[Content]{0}[Column1]

 
Posted : 05/06/2020 12:00 pm
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

Thank you Catalin. 

Ok great, this is what i wanted to know!

Best Wishes,
Jacek

 
Posted : 06/06/2020 2:40 am
Share: