Power Query Custom Column

jstevens
GoldLounger
Posts: 2628
Joined: 26 Jan 2010, 16:31
Location: Southern California

Power Query Custom Column

Post by jstevens »

I'm having a challenge resolving a formula in a custom column. Expression.Error: The name 'Range' wasn't recognized. Make sure it's spelled correctly.
EL_95.PNG
You do not have the required permissions to view the files attached to this post.
Regards,
John

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Power Query Custom Column

Post by Rudi »

Hi John.

That is not a valid formula in PQ.
No Range function exists in PQ and the syntax is also incorrect. You cannot refer to a field in double quotes.

Can you either give more details about what you are trying to calculate or provide a sample workbook that contains source data and your query so I can understand the content of this calculation and assist.

TX.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

jstevens
GoldLounger
Posts: 2628
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Power Query Custom Column

Post by jstevens »

Rudi,

I came to the conclusion that a Range function did not exist in PQ. What works is ...

Code: Select all

Sheets("Sheet1").ListObjects("MyTable").DataBodyRange.Columns(1).Resize(, 1) = Range("R_Month")
PQ is very versatile and thank you for mentioning it in one of your previous posts.
Regards,
John

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Power Query Custom Column

Post by Rudi »

Hi John,

Glad to hear your comments on PQ. It is a great product.

I am a bit confused though as the code you post has nothing to do with PQ. This is a VBA code.

It seems your question is resolved, so no need to add anything more from my side. :thumbup:
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

jstevens
GoldLounger
Posts: 2628
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Power Query Custom Column

Post by jstevens »

Rudi,

Since there is no Range function in PQ there is nothing else you need to do on your side. I went with a VBA solution which in the end updated the appropriate table records.
Regards,
John

User avatar
rory
5StarLounger
Posts: 817
Joined: 24 Jan 2010, 15:56

Re: Power Query Custom Column

Post by rory »

I suspect you could achieve the relevant effect in PQ directly but, as Rudi said, you'd need to provide a workbook so we can see what's going on.
Regards,
Rory

jstevens
GoldLounger
Posts: 2628
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Power Query Custom Column

Post by jstevens »

Rory/Rudi,

Here is a sample workbook and flat file for the table. I have included notes within the workbook.
el_Table.xlsm
myTextFile.txt
You do not have the required permissions to view the files attached to this post.
Regards,
John

User avatar
rory
5StarLounger
Posts: 817
Joined: 24 Jan 2010, 15:56

Re: Power Query Custom Column

Post by rory »

You can create a new query that just returns the range using:

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

and call it say Range.

Then create a custom column in your existing query using just =Range as the formula, then expand the table.
Regards,
Rory

jstevens
GoldLounger
Posts: 2628
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Power Query Custom Column

Post by jstevens »

Thank you Rory!

I got it to work with one minor modification to the custom column which I added to the existing query.
EL_97.PNG

Range = New query named "Range"
[Month] = Field heading in query
{0} = 1st record in query connection results.
You do not have the required permissions to view the files attached to this post.
Regards,
John

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Power Query Custom Column

Post by Rudi »

Glad its working John. :cheers:
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.