Solved

IIF Statement

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

840 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