PC Review


Reply
Thread Tools Rate Thread

Conditional Expression

 
 
Nona
Guest
Posts: n/a
 
      31st Oct 2008
In a query, Access calculates a utilization rate by dividing the number of
units used by the number of units approved. (Named "burnrate" in the
expression entered in the query) No problem with that. However, Access
returns an error if a value for the number of units approved has not been
entered, is null or zero. And it's impossible to get an average of all the
records.

I'm sure there must be a simple solution, but I haven't been able to come up
with it. I will appreciate your help!


--
Nona
 
Reply With Quote
 
 
 
 
Beetle
Guest
Posts: n/a
 
      31st Oct 2008
Use the Nz function to convert nulls. In your case it might look like;

[UnitsUsed]/Nz([UnitsApproved], 0)

or something similar
--
_________

Sean Bailey


"Nona" wrote:

> In a query, Access calculates a utilization rate by dividing the number of
> units used by the number of units approved. (Named "burnrate" in the
> expression entered in the query) No problem with that. However, Access
> returns an error if a value for the number of units approved has not been
> entered, is null or zero. And it's impossible to get an average of all the
> records.
>
> I'm sure there must be a simple solution, but I haven't been able to come up
> with it. I will appreciate your help!
>
>
> --
> Nona

 
Reply With Quote
 
Ken Sheridan
Guest
Posts: n/a
 
      31st Oct 2008
Fraid not; that would involve division by zero, which is mathematically
impossible, so would still give an error. If a result of zero is required
for Null or zero units approved then:

IIF(Nz([UnitsApproved],0)>0,[UnitsUsed]/[UnitsApproved],0)

If a result of Null is required:

IIF(Nz([UnitsApproved],0)>0,[UnitsUsed]/[UnitsApproved],NULL)

Ken Sheridan
Stafford, England

"Beetle" wrote:

> Use the Nz function to convert nulls. In your case it might look like;
>
> [UnitsUsed]/Nz([UnitsApproved], 0)
>
> or something similar
> --
> _________
>
> Sean Bailey
>
>
> "Nona" wrote:
>
> > In a query, Access calculates a utilization rate by dividing the number of
> > units used by the number of units approved. (Named "burnrate" in the
> > expression entered in the query) No problem with that. However, Access
> > returns an error if a value for the number of units approved has not been
> > entered, is null or zero. And it's impossible to get an average of all the
> > records.
> >
> > I'm sure there must be a simple solution, but I haven't been able to come up
> > with it. I will appreciate your help!
> >
> >
> > --
> > Nonap


 
Reply With Quote
 
Nona
Guest
Posts: n/a
 
      31st Oct 2008
I get the error message even if the number of approved units is zero. If I
enter "1" as the value, then I no longer get the error message.

I don't particularly want to have "1" as a default value for new auths since
it would skew the numbers (but not by much) so that's one possible solution.




--
Nona


"Beetle" wrote:

> Use the Nz function to convert nulls. In your case it might look like;
>
> [UnitsUsed]/Nz([UnitsApproved], 0)
>
> or something similar
> --
> _________
>
> Sean Bailey
>
>
> "Nona" wrote:
>
> > In a query, Access calculates a utilization rate by dividing the number of
> > units used by the number of units approved. (Named "burnrate" in the
> > expression entered in the query) No problem with that. However, Access
> > returns an error if a value for the number of units approved has not been
> > entered, is null or zero. And it's impossible to get an average of all the
> > records.
> >
> > I'm sure there must be a simple solution, but I haven't been able to come up
> > with it. I will appreciate your help!
> >
> >
> > --
> > Nona

 
Reply With Quote
 
Ken Sheridan
Guest
Posts: n/a
 
      31st Oct 2008
Nona:

See my response above.

Ken Sheridan
Stafford, England

"Nona" wrote:

> I get the error message even if the number of approved units is zero. If I
> enter "1" as the value, then I no longer get the error message.
>
> I don't particularly want to have "1" as a default value for new auths since
> it would skew the numbers (but not by much) so that's one possible solution.
>
>
>
>
> --
> Nona
>
>
> "Beetle" wrote:
>
> > Use the Nz function to convert nulls. In your case it might look like;
> >
> > [UnitsUsed]/Nz([UnitsApproved], 0)
> >
> > or something similar
> > --
> > _________
> >
> > Sean Bailey
> >
> >
> > "Nona" wrote:
> >
> > > In a query, Access calculates a utilization rate by dividing the number of
> > > units used by the number of units approved. (Named "burnrate" in the
> > > expression entered in the query) No problem with that. However, Access
> > > returns an error if a value for the number of units approved has not been
> > > entered, is null or zero. And it's impossible to get an average of all the
> > > records.
> > >
> > > I'm sure there must be a simple solution, but I haven't been able to come up
> > > with it. I will appreciate your help!
> > >
> > >
> > > --
> > > Nona


 
Reply With Quote
 
Nona
Guest
Posts: n/a
 
      31st Oct 2008
Perfect!

Thanks Very Very Much!
--
Nona


"Ken Sheridan" wrote:

> Nona:
>
> See my response above.
>
> Ken Sheridan
> Stafford, England
>
> "Nona" wrote:
>
> > I get the error message even if the number of approved units is zero. If I
> > enter "1" as the value, then I no longer get the error message.
> >
> > I don't particularly want to have "1" as a default value for new auths since
> > it would skew the numbers (but not by much) so that's one possible solution.
> >
> >
> >
> >
> > --
> > Nona
> >
> >
> > "Beetle" wrote:
> >
> > > Use the Nz function to convert nulls. In your case it might look like;
> > >
> > > [UnitsUsed]/Nz([UnitsApproved], 0)
> > >
> > > or something similar
> > > --
> > > _________
> > >
> > > Sean Bailey
> > >
> > >
> > > "Nona" wrote:
> > >
> > > > In a query, Access calculates a utilization rate by dividing the number of
> > > > units used by the number of units approved. (Named "burnrate" in the
> > > > expression entered in the query) No problem with that. However, Access
> > > > returns an error if a value for the number of units approved has not been
> > > > entered, is null or zero. And it's impossible to get an average of all the
> > > > records.
> > > >
> > > > I'm sure there must be a simple solution, but I haven't been able to come up
> > > > with it. I will appreciate your help!
> > > >
> > > >
> > > > --
> > > > Nona

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Expression help =?Utf-8?B?THVjaWVu?= Microsoft Access Queries 2 25th Sep 2006 08:37 PM
## conditional expression =?Utf-8?B?SnVzdGluZQ==?= Microsoft Access Queries 1 14th Sep 2006 09:02 PM
Conditional Expression =?Utf-8?B?bmF0YWxpZQ==?= Microsoft Access Macros 1 8th Sep 2006 06:35 PM
Conditional Expression =?Utf-8?B?S2VycnlK?= Microsoft Access Queries 2 14th Mar 2006 07:59 PM
IIf conditional expression =?Utf-8?B?Umlja0s=?= Microsoft Access Form Coding 3 8th Mar 2004 05:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:33 AM.