• 0

# Calculated field error message

## Question

Hi there,

I have a formula that is working fine in most instances, but it falls down every once in a while.  I think I've got it figured out and then it falls down again!

This is my code

`IsNull((SELECT sum(IsNull([@field:Optimiser_RatingX],0)+IsNull([@field:QA_Tester_RatingX],0)) FROM Card_comments_and_updates WHERE User_ID=[@field:Analyst_IDX])/((SELECT COUNT(IsNull([@field:Optimiser_RatingX],0)) FROM Card_comments_and_updates WHERE IsNull([@field:Optimiser_RatingX],0) >0  AND User_ID=[@field:Analyst_IDX])+(SELECT COUNT(IsNull([@field:QA_Tester_RatingX],0)) FROM Card_comments_and_updates WHERE IsNull([@field:QA_Tester_RatingX],0) >0 AND User_ID=[@field:Analyst_IDX])),0)`

I want it to display zero if it can't calculate anything!

Basically my datapage displays all my users along with an average of all the star ratings they have.  The calculated field looks in a different table for every instance where the user ID in this table is listed in the Analyst column.  Then it checks the 2 different fields where ratings are given (QA Tester Rating and Optimiser rating) for values more than 0.  Adds them together and then divides them by the count, thereby giving the average.  For the most part it works fine ... EXCEPT where there are fields where either the QA Tester Rating or Optimiser Rating are zero.

Help!

Many thanks

Nikki

## Recommended Posts

• 0

Since you have a division make sure you are not dividing by 0 by adding case statement

CASE WHEN XXX = 0 THEN 1 ELSE XXXX END

##### Share on other sites

• 0

Hello!

Just to add, here's the link to known errors and messages and how to solve them: https://howto.caspio.com/troubleshooting/errors-and-messages/

Included here is on how to avoid dividing values with 0.

Hope this helps.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.