• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

IIF Statement

Having trouble with the following statement.

What I'm trying to get is that if Southern Brand = Florida, or Southern Brand = Georgia give me etc.


VOLUME PCT:IIF([tbl_SumofValues].[Southern Brand]="Florida" and [tbl_SumofValues].[Southern Brand]="Georgia),"[Format([Volume]/[SumofVolume]*100,"#,##0.000000000)/6]","[Format([Volume]/[SumofVolume]*100,"#,##0.000000000(Format([Volume]/[SumofVolume]*100,"#,##0.000000000])"
0
mato01
Asked:
mato01
  • 2
  • 2
1 Solution
 
tomHamillCommented:
I'm not sure if this is a typo in your question or if that code snip is what you're actually using, but the code you've provided uses "AND" when your question says you're looking for "OR."

The formula in your question will only do the calculation if the SouthernBrand field equals both Florida and Georgia.  I assume that will never happen.

Anyway, try replacing the AND with OR.  You could also use nested if statements like

=IF([SouthernBrand] = "Flordia", Calculate,
     IF([SouthernBrand]="Georgia", Calculate, do whatever you need to do for other states))

Tom
0
 
mato01Author Commented:
Okay, I'm trying to use the Nested Statements, but still getting an syntax error.  

VOLUME PCT: IIf([tbl_SumofValues].[Southern Brand]="Florida",
Format([Volume]/[SumofVolume]/6*100,
IIf([tbl_SumofValues].[Southern Brand]="Georgia",
Format([Volume]/[SumofVolume]/6*100,
“Format([Volume]/[SumofVolume]*100")))
0
 
tomHamillCommented:
A couple of things that might be helpful as you ask these questions...

1) Please tell the community what program you're using.  The question is listed (for me, at least) as "Excel, VBA." Your code snips look more like Access so I've been assuming you're using Access.  Am I correct?

2) Don't tell the community you're "getting a syntax error."  Tell us what the error says!

At any rate, it looks to me like your problem(s) are in the FORMAT statements.  The first two don't appear to have a closing parenthesis.  What are these format statements doing, by the way?  Are they really necessary, or could you just return the value of the arithmetic?

I'd encourage you to try the "OR" clause so that you don't have to maintain the arithmetic in two places.  Something like

Volume_PCT: IIF([tbl_SumOfValues].[Southern Brand]="Florida" Or [tbl_SumOfValues].[Southern Brand]="Georgia", Format([Volume]/[SumOfVolume]/6*100), Format([Volume]/[SumOfVolume]*100))

Should work.
0
 
mato01Author Commented:
Thanks for the lecture.  I do need to be more careful on how i format my questions.  It's all a learning process for me.

Works perfectly.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now