Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Can I Make a Calculated Field that Returns a Zero if the Calculation Would Result in an Error Due to a Zero in the Denominator?

Posted on 2011-09-09
3
Medium Priority
?
241 Views
Last Modified: 2012-05-12
I am trying to make a ratio of the Total_QNs/Total_Shipped....However, sometimes One or both of those fields is a zero, which returns an error. I would like it to return the ratio if there is data, or a zero if the denominator or numerator is a zero
0
Comment
Question by:Rex85
  • 2
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 36513191
iif(Total_QNs = 0 OR Total_Shipped = 0,0,  Total_QNs/Total_Shipped)
0
 

Author Closing Comment

by:Rex85
ID: 36513207
Thank you!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36513209
Glad to help out :)

In explanation the IIf function evaluates an expression to see if it is tru or false and then returns a value based on that determination.

IIf(someExpression, ReturnThisIfTrue, ReturnThisIfFalse)
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

916 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