# Error Messages/42652

## Example warning message

A result differs from what would be computed by releases before Analytica 4.4.
 The function Sum was applied to an array containing only Null values.
 The Analytica 4.4 result is Null, while 4.3 and earlier releases return 0.

## Cause

Bug fixes in Analytica 4.4 implement a more uniformly consistent treatment of the case in which functions are applied to arrays containing only Null values. The general principle that has been followed by most Analytica functions is that the result of applying an array function to an array of Null values should be Null. However, up through 4.3, several legacy functions lingered that did not abide by this principle.

The fact that this has occurred might not have any impact on your final results, and indeed often it does not. In other cases, it may trigger an error that was not previous reported, or you may see Null values propagate to your final result where 0s existed previously. This warning is helpful for finding where these cases occur.

#### Consistent treatment

Suppose A := Array(I, [Null, Null, Null]). Then a consistent behavior by array functions (i.e., Analytica 4.4) would be:

Sum(A,I) → Null
Max(A,I) → Null
ArgMax(A, I) → Null
Product(A, I) → Null
Average(A, I) → Null
Npv(2%, A, I) → Null
SDeviation(A, I) → Null
Area(A, I) → Null
etc

#### Inconsistent cases pre-4.4

In pre-4.4 releases, not all functions treated the all-Null case in this fashion. Here are the values returned for each case in Analytica 4.3:

Function call result
(A is all-Null)
result
(when Size(I)=0)
Sum(A, I) 0
Product(A, I) 1
Area(A, I) 0
Average(A, I) NaN
SDeviation(A, I) NaN Undefined
Variance(A, I) NaN 0
Skewness(A, I) NaN 0
Kurtosis(A, I) NaN 0
ArgMin(A, I) Size(I) Null
ArgMax(A, I) Size(I) Null

## Remedy

Several remedies are possible:

1. Visit the place in the model where this occurs and ensure that your model does the right thing when Null is returned.
2. Turn off just this warning, use the consistent Null result computed by Analytica 4.4.
3. Ignore all warnings (not recommended)
4. Set a system variable to return the Analytica 4.3 result values for full backward compatibility.

Doing both Options 1 and 2 is the recommended course of action. If this is causing changes to your end results, then Option 4 is the easy way to achieve quick backward compatibility; however, we recommend that you take option 1 & 2 instead when possible.

### Model fixes

In many cases, the fact that a given function is returning Null in the all-Null case will not actually impact your final result. For example:

Sum([7, Sum(A, I)]) → 7

This evaluates the same in both cases, when Sum(A, I) → 0 and when Sum(A, I) → Null. This is because the outer Sum either adds 0 for the second item, which has no impact on the total sum, or ignores the Null, which also has no impact on the total sum.

However, when the result is subjected to binary operators, +, -, *, /, or ^, or comparisons, <, ≤, <>, or =, then the net result will be Null. Binary operators return Null when either value is Null. It is predominantly these cases that could impact your model's end results.

7 + Sum(A, I) → Null { in Analytica 4.4 }
7 + Sum(A, I) → 7 { in Analytica 4.3 }

### Turning off warnings

The flag to warn about this situation is enabled when you load a legacy model into Analytica 4.4 (i.e., a model that had been created in Analytica 4.3 or earlier). Once you are confident that this condition does not impact your model's results, you will want to turn it off. This is done from typescript. Press F12, then type:

Sys_AllNullTreatment: 0

A value of 1 enables this set of warnings, while 0 turns them off.

### Using Legacy results

If you decide you want to stick with the pre-4.4 results for full easy backward compatibility (and the less-consistent treatment of Nulls), then you can set a flag for this from typescript. Press F12 then type:

Sys_AllNullTreatment: 4

If you are impacted by only one or two cases, you may opt to toggle legacy treatment on a finer grain level. You can control whether the legacy pre-4.4 value is returned individually for each impacted function by treating Sys_AllNullTreatment as a bit-field with the following bits:

When to use Legacy value Bit
Warning non-Legacy 1
Warning Legacy value 2
All functions 4
Sum 8
Product 16
Average 32
Area 64
SDeviation
Variance
Skewness
Kurtosis
128
ArgMin
ArgMax
256

Bits 1 and 2 control when warnings are issued. Bit 1 causes warnings when an all-Null case is encountered and result will be Null (the consistent treatment), which might signal a break with backward compatibility. Bit 2 causes warnings when an all-Null case is encountered by the flags are set to return the legacy value.

Setting Sys_AllNullTreatment to 4 covers all functions, and is equivalent to setting it to 128 + 64 + 32 + 16 + 8

Setting Sys_AllNullTreatment := 8 + 16 causes Sum and Product to behave as in Analytica 4.3 for the all-Null case, but all other functions exhibit the more consistent 4.4 behavior.

Users of Analytica Player or Power Player, or of read-only models, will not be able to change Sys_AllNullTreatment. You will need to contact the model author and request this change.

### Invalidation

When you change Sys_AllNullTreatment, previously computed results are not invalidated. Thus, after making the change, you should save and reload your model.