Avoiding error in Business Logic condition

There can be an error in business logic condition, if there is a variable used in that condition and its formula results in an error.


Example:
You have created a variable dummy_var using a data with columns Country and Sales.

dummy_var =
Values(GroupbyCategory(‘Country’, ‘Sales’), 30)

Further, you configure a business logic wherein
There’s a condition:

dummy_var < 5000000

Now,
Basis the given dataset, if at some point the number of countries are less than 30, there will be an error in the calculation of ‘dummy_var’.

However, till this point it won’t matter. Moving ahead, when in the condition variable ‘dummy_var’ is needed, there shall be an error since ‘dummy_var’ wasn’t calculated.

To avoid this:

Apply the condition in such a way that the value on which variables calculation is dependant is added as a parent condition before the actual condition.

In this case,
dummy_var depends on the number of countries in the data, which can be calculated using Length(Unique(Countries)).

Let’s create a variable for the same,
no_of_countries

Hence, our condition will be:
no_of_countries >= 30
dummy_var < 5000000