Solved

IIF Statement

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Exchange 2007 SP upgrade 9 97
Excel VBA: Nested Areas in a Range object ? 6 91
Excel - Locking a Sheet 6 55
MS Project Resource Pool - Material and Cost sharing vs Work 1 56
The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
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…
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 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…

803 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