Custsom Formula for Null results

L

Love Buzz

Hi there.

I have two queuries that are connected and everything is working fine except
that my formula isn't reflected when one of the columns is blank.

Here is my formula:

Expr1: ([Redeposit Analysis: RR Code 1.CountOfRR Code]-[Redeposit Analysis:
RR Code 2.CountOfRR Code])/[Redeposit Analysis: RR Code 1.CountOfRR Code]

How can I have any blank field for RR Code 1 or RR Code 2 reflect zero when
the field is blank?

Thanks for your help.
 
K

KARL DEWEY

Your syntax is wrong. I assume that your table is [[Redeposit Analysis: [RR
Code 1] and you have a field [CountOfRR Code] and then another table
[Redeposit Analysis: RR Code 2] with field [CountOfRR Code].

Your formula would be ----
Expr1: ([Redeposit Analysis: RR Code 1].[CountOfRR Code] - [Redeposit
Analysis:
RR Code 2].[CountOfRR Code])/[Redeposit Analysis: RR Code 1].[CountOfRR Code]
 
L

Love Buzz

Thanks Karl. The output is exactly the same no mater which syntax I use
(yours or mine). My question is how do I convert any blank fields from the
output of CountOfRR Code 2 to zero so that my pecentage comes out correctly?

KARL DEWEY said:
Your syntax is wrong. I assume that your table is [[Redeposit Analysis: [RR
Code 1] and you have a field [CountOfRR Code] and then another table
[Redeposit Analysis: RR Code 2] with field [CountOfRR Code].

Your formula would be ----
Expr1: ([Redeposit Analysis: RR Code 1].[CountOfRR Code] - [Redeposit
Analysis:
RR Code 2].[CountOfRR Code])/[Redeposit Analysis: RR Code 1].[CountOfRR Code]

--
Build a little, test a little.


Love Buzz said:
Hi there.

I have two queuries that are connected and everything is working fine except
that my formula isn't reflected when one of the columns is blank.

Here is my formula:

Expr1: ([Redeposit Analysis: RR Code 1.CountOfRR Code]-[Redeposit Analysis:
RR Code 2.CountOfRR Code])/[Redeposit Analysis: RR Code 1.CountOfRR Code]

How can I have any blank field for RR Code 1 or RR Code 2 reflect zero when
the field is blank?

Thanks for your help.
 
K

KARL DEWEY

Try this --
Expr1: IIF(([Redeposit Analysis: RR Code 1].[CountOfRR Code] - [Redeposit
Analysis: RR Code 2].[CountOfRR Code])=0 OR [Redeposit Analysis: RR Code
1].[CountOfRR Code] = 0 OR [Redeposit Analysis: RR Code 2].[CountOfRR Code] =
0, 0, ([Redeposit Analysis: RR Code 1].[CountOfRR Code] - [Redeposit
Analysis: RR Code 2].[CountOfRR Code])/[Redeposit Analysis: RR Code
1].[CountOfRR Code])

--
Build a little, test a little.


KARL DEWEY said:
Your syntax is wrong. I assume that your table is [[Redeposit Analysis: [RR
Code 1] and you have a field [CountOfRR Code] and then another table
[Redeposit Analysis: RR Code 2] with field [CountOfRR Code].

Your formula would be ----
Expr1: ([Redeposit Analysis: RR Code 1].[CountOfRR Code] - [Redeposit
Analysis:
RR Code 2].[CountOfRR Code])/[Redeposit Analysis: RR Code 1].[CountOfRR Code]

--
Build a little, test a little.


Love Buzz said:
Hi there.

I have two queuries that are connected and everything is working fine except
that my formula isn't reflected when one of the columns is blank.

Here is my formula:

Expr1: ([Redeposit Analysis: RR Code 1.CountOfRR Code]-[Redeposit Analysis:
RR Code 2.CountOfRR Code])/[Redeposit Analysis: RR Code 1.CountOfRR Code]

How can I have any blank field for RR Code 1 or RR Code 2 reflect zero when
the field is blank?

Thanks for your help.
 
J

John Spencer

Try using the NZ function to force zero for nulls

(Nz([Redeposit Analysis: RR Code 1].[CountOfRR Code],0) -
NZ([Redeposit Analysis: RR Code 2].[CountOfRR Code],0))/
[Redeposit Analysis: RR Code 1].[CountOfRR Code]

You still have a problem if [Redeposit Analysis: RR Code 1].[CountOfRR Code]
is zero, since in that case you will get a divide by zero error.

You can test for that using an IIF statement.

IIF(Nz([Redeposit Analysis: RR Code 1].[CountOfRR Code],0)=0,
, Null
, (Nz([Redeposit Analysis: RR Code 1].[CountOfRR Code],0) -
NZ([Redeposit Analysis: RR Code 2].[CountOfRR Code],0))/
[Redeposit Analysis: RR Code 1].[CountOfRR Code])

If you want to return some value other than null, replace null with that value
or an expression that will generate the value you want.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Love said:
Thanks Karl. The output is exactly the same no mater which syntax I use
(yours or mine). My question is how do I convert any blank fields from the
output of CountOfRR Code 2 to zero so that my pecentage comes out correctly?

KARL DEWEY said:
Your syntax is wrong. I assume that your table is [[Redeposit Analysis: [RR
Code 1] and you have a field [CountOfRR Code] and then another table
[Redeposit Analysis: RR Code 2] with field [CountOfRR Code].

Your formula would be ----
Expr1: ([Redeposit Analysis: RR Code 1].[CountOfRR Code] - [Redeposit
Analysis:
RR Code 2].[CountOfRR Code])/[Redeposit Analysis: RR Code 1].[CountOfRR Code]

--
Build a little, test a little.


Love Buzz said:
Hi there.

I have two queuries that are connected and everything is working fine except
that my formula isn't reflected when one of the columns is blank.

Here is my formula:

Expr1: ([Redeposit Analysis: RR Code 1.CountOfRR Code]-[Redeposit Analysis:
RR Code 2.CountOfRR Code])/[Redeposit Analysis: RR Code 1.CountOfRR Code]

How can I have any blank field for RR Code 1 or RR Code 2 reflect zero when
the field is blank?

Thanks for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top