S
steveh
I build simple Excel queries through Excel's Microsoft Query and send
them to clients. They operate off a SQL Server database.
Is there a way to use the IIf function or Case When statement in one of
these .dqy queries? When I try to use IIf, MS Query doesn't complain
about IIf, but I can't get past an "Incorrect syntax near '=' message
when I try to run the query.
Here's part of my query:
Sum(IIf(CRType='W', -CRAmount, CRAmount))
I've also tried without success the following:
Sum(Case When CRType="W" Then -CRAmount Else CRAmount End)
Any ideas? Is it even possible? This needs to be done in Microsoft Query
and saved as a .dqy file. I can do this using Access or VBA in Excel, so
I am not looking for that type of solution.
Thanks for looking.
them to clients. They operate off a SQL Server database.
Is there a way to use the IIf function or Case When statement in one of
these .dqy queries? When I try to use IIf, MS Query doesn't complain
about IIf, but I can't get past an "Incorrect syntax near '=' message
when I try to run the query.
Here's part of my query:
Sum(IIf(CRType='W', -CRAmount, CRAmount))
I've also tried without success the following:
Sum(Case When CRType="W" Then -CRAmount Else CRAmount End)
Any ideas? Is it even possible? This needs to be done in Microsoft Query
and saved as a .dqy file. I can do this using Access or VBA in Excel, so
I am not looking for that type of solution.
Thanks for looking.