# Using functions in MDX logic script

How can i use MDX functions like ABS, SIGN etc. in logic scripts?

Actually, i would like to save always positive values for example for revenues.

The script could be like that:

*WHEN ACCOUNT.ACCTYPE

*IS EXP

*REC(EXPRESSION = ABS(%VALUE%))

*ENDWHEN

*COMMIT

But this gives a validation error "RefferenceError: ABS is not defined".

Maybe there is some other way to save the absolute value or to change sign in case the value is negative?

##### Tags:

##### Vadim Kalinin replied

Hi Natalija,

The only conditional operator supported is ternary operator:

EXPRESSION or FACTOR=LogicalTest ? ExpressionIfTrue : ExpressionIfFalse

Like:

*REC(EXPRESSION=%VALUE%>0 ? %VALUE%*2 : 0)

If current value greater then zero then write current value multiplied by 2, else - write zero.

Fob BPC NW 10 with ABAP calculation engine nested ternary operator is **not** supported, with JAVASCRIPT calculation engine - nested is supported.

B.R. Vadim