Calculated metrics: create metrics expression

289 views Asked by At

I want to create Calculated metrics expression for same Logical expression for example by Java

if (KPI<=95 & FailedCount!=0) {

STATUS=1;}

else {STATUS=0;}

In Site Scope I wrote this expression

((<<KPI>><=95)&(<<FailedCount>>!=0))

But I do not like the result

When KPI=0 and FailedCount=0;

STATUS=0,

then KPI=100 and FailedCount=0

STATUS='n/a'.

How to reslove this problem?

p.s. Add question on HP Community too

1

There are 1 answers

0
Bence Szalai On

There's a ternary operator you can use:

(Boolean Expression)? resultIfExpressionIsTrue: resultIfExpressionIsFalse

In your case you could try to use something like:

((<<KPI>><=95)&(<<FailedCount>>!=0))? 1: 0

You may also need to consider if you want the result to be 0 and 1 as integers (as above) or as strings in which case they should be put in between " marks. This is important from the perspective if you'd like to apply arithmetic or string like thresholds to the resulting calculated metric, also if you'd like the result to be seen as numeric or string values in other places, like in OMi or Service Health etc.