Undefined Function in Expression

neilshah

New Member
Joined
Mar 5, 2004
Messages
5
I have a query in the database which has an expression 'MonthName' in it. I used that expression to convert month number from the table to the month name. It worked great in the query, but now when I am trying to create a Pivot Table in Excel from the same query it's giving me this error message - Undefined Function 'MonthName' in expression.

Any suggestions on how to make this work.

Thanks.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
From what you have described, it sounds like "MonthName" is just the name of a field you are calculating in a query. It is not a function, hence you probably can't use it as a function.

If you want to use it as a function, you would have to create it as a user-defined function in VBA.
 
Upvote 0
'MonthName' is both the name of the field and the function in the query. Here is what my expression looks like

MonthName: MonthName((Month(tbl_3YearData!Start Date)),True)

This expression takes the month number from the table and returns the month name. It works perfectly fine in Access, but when I try to create a Pivot table in Excel I get the error message - Undefined Function 'MonthName' in expression. Why??

Thanks.
 
Upvote 0
Using the same name for both is probably causing the problem. What does the function do?

Peter
 
Upvote 0
I tried changing the name too, but it did not work. The function takes the date, for example 3/19/04, and returns a month i.e. 3. Then it shows the month name i.e. March. That is the final output.

Thanks.
 
Upvote 0
You could try doing it directly in the query with
NewMonth: Format([tbl_3YearData!Start Date],"mmmm")

HTH

Peter
 
Upvote 0

Forum statistics

Threads
1,221,645
Messages
6,161,044
Members
451,682
Latest member
ogoreo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top