Override #ERR to Prevent Error Propagation?
Consider a case where you might want to compute the Sum of the areas for multiple blobs found by an ExtractBlobs tool. You use the GetArea function to retrieve the area of individual blobs from the blob structure. If a blob is not found, the GetArea function will fail, but this may be a valid scenario in your application.
|
Cell |
Function |
Description |
|---|---|---|
|
A1 |
ExtractBlobs([Parameters]) |
Extracts blobs and returns a Blobs structure. |
|
B1 |
GetArea(A1,0) |
Returns the area of Blob 0. |
|
B2 |
GetArea(A1,1) |
Returns the area of Blob 1. |
|
B3 |
GetArea(A1,2) |
Returns the area of Blob 2. |
|
B4 |
Sum(B1:B3) |
Computes the sum of the blob areas. |
|
If the ExtractBlobs tool fails to locate at least 3 blobs, then the formula Sum(B1:B3) will report #ERR because at least one cell referenced by this formula will also report #ERR. To override this error condition, you can utilize the ErrFree function as follows: |
||
|
B4 |
Sum(ErrFree(B1:B3)) |
Computes the sum of the blob areas. |
When using the ErrFree function, the input values from other cells reporting #ERR will be converted to a value of 0; in this case, the Sum function will replace 0 for any input #ERR cell instead of reporting an error. For more information, see Lookup.