Re: IIF question
- From: "LP" <LP@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 29 Jul 2005 10:02:03 -0700
I have an additional hurdle of handling the "NA" because the field is a
numeric field and I get errors from trying to put a string in a numeric field.
Any thoughts?
"fredg" wrote:
> On Thu, 28 Jul 2005 13:46:04 -0700, LP wrote:
>
> > It's been awhile since I've done any Access queries and I need to calculate a
> > variance on actual sales vs forcast sales for a week. Below is what I've
> > tried.
> >
> > SalesPerVar: IIf(([MForcastSales] And
> > [MActSales])=0,0,IIf(([MForcastSales]=0 And
> > [MActSales])>0,"NA",([MForcastSales]-[MActSales])/[MForcastSales]*100))
>
> What are you trying to do here?
> IIf(([MForcastSales] And [MActSales])=0
>
> 1) Is this supposed to literally add the two fields? Then:
> IIf([MForcastSales]+[MActSales]=0, 0, .....
>
> 2) Are you checking that each field = 0? Then:
> IIf([MForcastSales] = 0 And [MActSales]=0, 0, ......
>
> Probably #2.
>
> Note: you also have the parentheses (which are not needed) in the
> wrong position in the criteria portion of both IIf's. The closing one,
> if you use parentheses, belongs after the =0, not before it.
>
> IIf(([MForcastSales] And [MActSales])=0
> should be
> IIf(([MForcastSales] And [MActSales]=0)
>
> IIf(([MForcastSales]=0 And [MActSales])> 0
> should be
> IIf([MForcastSales]=0 And [MActSales]> 0)
>
> Try this:
> IIf([MForcastSales] = 0 And [MActSales]= 0, 0, IIf([MForcastSales]=0
> And [MActSales] >0, "NA" , ([MForcastSales]-[MActSales])/
> [MForcastSales] *100))
>
> --
> Fred
> Please only reply to this newsgroup.
> I do not reply to personal email.
>
.
- References:
- IIF question
- From: LP
- Re: IIF question
- From: fredg
- IIF question
- Prev by Date: Only Show records with latest date by vendor
- Next by Date: RE: append query
- Previous by thread: Re: IIF question
- Next by thread: parameter prompted twice
- Index(es):
Relevant Pages
|
|