32
Views
4
Solved
###### How do I handle dividing by zero?
Question

Hi everybody,

I have built a report page where I have a couple of expressions to calculate (for example) the average age of my employees, the average amount of hours they work per week etc. and I made it possible for the end-user to specify a quarter for which they would like to see the data. However, for some quarters there is simply no data yet, which means the results are divided by zero, generating the following message:

How do I handle the exception so that this message does not show?

Solution

Hi Lotte,

can you show the Oml?

Putting an IF clause in the calculation, to set the result as "0" or empty when the quarter still have no data doesn't work?

Solution

Dear Lotte

Please do remember that you are using the application for front-end users and it is calculating the average on data selection. So, to calculate avg it says = (Sum of data) / (Count of data)

In some cases, you do not have data which throws 0 / 0 and exception occurs.

Here if your intention is only to avoid the message you can use what @Samiksha Manekar has advised and it may solve the problem.

But for the end user if no data will appear could be confusing and look like application bug. You should one condition of "No Data Found". So, if there is no data you should not run the Avg Operation but show the message of No Data Found.

Please feel free to ask in case of any question.

Solution

if( quarter = 0 , 0 , yourcalculation)

Solution

Hi,

You can put Exception Handler with allException.

Hope this works.

thanks

Solution

Hi Lotte,

can you show the Oml?

Putting an IF clause in the calculation, to set the result as "0" or empty when the quarter still have no data doesn't work?

Solution

Hi,

You can put Exception Handler with allException.

Hope this works.

thanks

Solution

if( quarter = 0 , 0 , yourcalculation)

Solution

Dear Lotte

Please do remember that you are using the application for front-end users and it is calculating the average on data selection. So, to calculate avg it says = (Sum of data) / (Count of data)

In some cases, you do not have data which throws 0 / 0 and exception occurs.

Here if your intention is only to avoid the message you can use what @Samiksha Manekar has advised and it may solve the problem.

But for the end user if no data will appear could be confusing and look like application bug. You should one condition of "No Data Found". So, if there is no data you should not run the Avg Operation but show the message of No Data Found.