Switch Function in Query Expression

Drand

Registered User.
Local time
Tomorrow, 04:13
Joined
Jun 8, 2019
Messages
179
Hi All

I am trying to use the switch function in a query.

The function I have created is:

YTDBud: Switch(Month(Date())=1,[sumofJan]),(Month(Date()) =2,[sumofJan]+[SumofFeb]

Where SumofJan and SumofFeb are fields in the query.

YTDBud: Switch(Month(Date())=1 returns the correct value for SumofJan but when I add the second expression I get an error message

"the expression you entered contains invalid sysntax,or you need to enclose your text data in quotes"

Is it possible to use the switch function the way I am attempting, and if so, what is the issue with my syntax?

Really appreciate your assistance.
 
You need to move the closing parens to the very end.

From ... [sumofJan]),

To ... + [SomOfFeb])

Hope that helps...
 
Thanks both for your responses. Both of which will work as I need it.

I was not aware of the choose function. This is far simpler than what I was attempting.

Again, many thanks
 
Thanks both for your responses. Both of which will work as I need it.

I was not aware of the choose function. This is far simpler than what I was attempting.

Again, many thanks
Glad we could assist. Good luck with your project.
 
For info, the Switch function cannot be used in a query unless it is used within a wrapper function.
i think this is wrong info. You can of course use Switch() inside a Query. Maybe you have mistaken it with Split function.
 
Oops. I need new glasses. I did indeed mean the Split function. Thanks
 

Users who are viewing this thread

Back
Top Bottom