Solved

IIF Statement

Posted on 2012-03-18
4
262 Views
Last Modified: 2012-03-19
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
Comment
Question by:mato01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:tomHamill
ID: 37737581
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
 

Author Comment

by:mato01
ID: 37738500
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
 
LVL 1

Accepted Solution

by:
tomHamill earned 200 total points
ID: 37738848
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
 

Author Closing Comment

by:mato01
ID: 37739354
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This collection of functions covers all the normal rounding methods of just about any numeric value.
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question