Solved

IIF Statement

Posted on 2012-03-18
4
249 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
  • 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now