3 Replies Latest reply on Oct 1, 2015 11:25 AM by Odarin

# Using presentation variables in calculations

Hi all,

I need to use a presentation variable in formula in my analysis. For example, the variable @{Tax} and the formula @{Tax}*"GL_SLA_DAILY"."TURNOVER". The variable type is a number, column type is also the number.

But when I look at the report analysis it turns out that instead of calculation result I get 0. (neither Tax nor Turnover are 0, just in case). When I replace the variable in formula by the specific number - it works, I also can get value of the variable (if I make formula just @{Tax}), but if I try @{Tax}*2 - it also dave 0 in result. So the problem is in performing operations with variables.

What should I do to make it works?

• ###### 1. Re: Using presentation variables in calculations

Think I got a kind of the solution. The addition and subtraction operations work normally without any tricks. To use the multiplication with the variable you need to get the variable in parentheses - (@{Variable})*2, then it works. This still doesn't work with division, but you can replace it with multiplication in separate cases.

But if someone know how to use just division with variables, I would be very grateful for your advices.

• ###### 2. Re: Using presentation variables in calculations

Straight away, one thing I can think of is trying to cast your formula arguments to double, something like:

cast(@{Variable} as double) / x

If that doesn't work you can try to cast both sides of the division

cast(@{Variable} as double) / cast(x as double)

• ###### 3. Re: Using presentation variables in calculations

Pedro F,

thank you for answer! Yes, indeed, casting to double helps.

I tried to cast into integer but seems that datatype was not suitable for my particular formula and I didn't guessed to use another datatype.