Hi, im having a problem with this expression. What I have done is get the error percentage, i.e, I have for example 643 transactions with 49 errors what I want is the error percentage. The expression work well but when I have 0 transactions and 0 errors I get an evident error [math] cannot divide by 0, is there a solution to avoid this problem?
This is what I have:
filters
|essql
query = {string "SELECT COUNT(document.name) as total1 FROM \"nowo_apicalls-dev*\" WHERE document.name = 'id-check' and document.statusCode BETWEEN 200 AND 299"}
| var_set name="field1" value={getCell "total1"}
| filters
| essql
query = {string "SELECT count(document.statusCode) as total2 FROM \"nowo_api_calls_int*\" where document.name = 'id-check' and document.statusCode != 200 "}
| var_set name="field2" value={getCell "total2"}
| var_set name ="result" value={math {string {var field1} " - " {var field2}}}
| filters
| essql
query = {string "SELECT count(document.statusCode) as total3 FROM \"nowo_api_calls_int*\" where document.name = 'id-check' and document.statusCode != 200 "}
| var_set name="field3" value={getCell "total3"}
| math {string {var field3} " / " {var result} * 100}
| formatnumber "0%"