Calculated field problem

G

Guest

I am using this expression in a text box to calculate a percentage of errors.

=CDbl([Prep_Err_txt].[Value])/IIf(CDbl([Prep_Batch_Total_txt].[Value])=0,1,CDbl([Prep_Batch_Total_txt].[Value]))

These are the expressions used for the Prep_Err-txt and Prep_Batch_Total_txt
fields, respectively.

=Nz([Prep_Batch_Total])

=Nz([SumByEmp_Ind_Prep.CountOfType of Error]) ' this field is from a
calculated field in a query.

This works fine except when the [Prep_Batch_Total_txt] field is blank. I
thought the Nz function would return a 0 (zero)? How can I modify this
expression to display a 0.00% when this occurs?

Your help is always appreciated.
 
G

Guest

You should use the NZ function as follow
=Nz([Prep_Batch_Total],0)=Nz([SumByEmp_Ind_Prep.CountOfType of Error],0) ' this field is from a

add the zero in the end, or any other value you want instead of the null.

Marianne said:
I am using this expression in a text box to calculate a percentage of errors.

=CDbl([Prep_Err_txt].[Value])/IIf(CDbl([Prep_Batch_Total_txt].[Value])=0,1,CDbl([Prep_Batch_Total_txt].[Value]))

These are the expressions used for the Prep_Err-txt and Prep_Batch_Total_txt
fields, respectively.

=Nz([Prep_Batch_Total])

=Nz([SumByEmp_Ind_Prep.CountOfType of Error]) ' this field is from a
calculated field in a query.

This works fine except when the [Prep_Batch_Total_txt] field is blank. I
thought the Nz function would return a 0 (zero)? How can I modify this
expression to display a 0.00% when this occurs?

Your help is always appreciated.
 
G

Guest

Thank you so much! That worked out great!

I have one problem left. Lines 1 and 2 below should be 100.00%. How do I
modify the expression so that whenever the "Completed" column is zero the
"Error % Rate" is 100.00%?

Here is the expression in the control source for the Error % Rate:

=CDbl([Prep_Err_txt].[Value])/IIf(CDbl([Prep_Batch_Total_txt].[Value])=0,1,CDbl([Prep_Batch_Total_txt].[Value]))

Completed Errors Error % Rate
1. 0 24 2400.00%
2. 0 2 200.00%
3. 75 6 8.00%
Totals: 75 32 42.67%


Ofer said:
You should use the NZ function as follow
=Nz([Prep_Batch_Total],0)=Nz([SumByEmp_Ind_Prep.CountOfType of Error],0) ' this field is from a

add the zero in the end, or any other value you want instead of the null.

Marianne said:
I am using this expression in a text box to calculate a percentage of errors.

=CDbl([Prep_Err_txt].[Value])/IIf(CDbl([Prep_Batch_Total_txt].[Value])=0,1,CDbl([Prep_Batch_Total_txt].[Value]))

These are the expressions used for the Prep_Err-txt and Prep_Batch_Total_txt
fields, respectively.

=Nz([Prep_Batch_Total])

=Nz([SumByEmp_Ind_Prep.CountOfType of Error]) ' this field is from a
calculated field in a query.

This works fine except when the [Prep_Batch_Total_txt] field is blank. I
thought the Nz function would return a 0 (zero)? How can I modify this
expression to display a 0.00% when this occurs?

Your help is always appreciated.
 
G

Guest

did you tr
iif([Completed]=0,100,CDbl([Prep_Err_txt].[Value])/IIf(CDbl([Prep_Batch_Total_txt].[Value])=0,1,CDbl([Prep_Batch_Total_txt].[Value]))
)

Marianne said:
Thank you so much! That worked out great!

I have one problem left. Lines 1 and 2 below should be 100.00%. How do I
modify the expression so that whenever the "Completed" column is zero the
"Error % Rate" is 100.00%?

Here is the expression in the control source for the Error % Rate:

=CDbl([Prep_Err_txt].[Value])/IIf(CDbl([Prep_Batch_Total_txt].[Value])=0,1,CDbl([Prep_Batch_Total_txt].[Value]))

Completed Errors Error % Rate
1. 0 24 2400.00%
2. 0 2 200.00%
3. 75 6 8.00%
Totals: 75 32 42.67%


Ofer said:
You should use the NZ function as follow
=Nz([Prep_Batch_Total],0)=Nz([SumByEmp_Ind_Prep.CountOfType of Error],0) ' this field is from a

add the zero in the end, or any other value you want instead of the null.

Marianne said:
I am using this expression in a text box to calculate a percentage of errors.

=CDbl([Prep_Err_txt].[Value])/IIf(CDbl([Prep_Batch_Total_txt].[Value])=0,1,CDbl([Prep_Batch_Total_txt].[Value]))

These are the expressions used for the Prep_Err-txt and Prep_Batch_Total_txt
fields, respectively.

=Nz([Prep_Batch_Total])

=Nz([SumByEmp_Ind_Prep.CountOfType of Error]) ' this field is from a
calculated field in a query.

This works fine except when the [Prep_Batch_Total_txt] field is blank. I
thought the Nz function would return a 0 (zero)? How can I modify this
expression to display a 0.00% when this occurs?

Your help is always appreciated.
 

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