Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Highlighted
qlikmpate0
Contributor II

Expression returning -0

I have the following expression

(sum(alt(AMOUNT_DUE_REMAINING,0))-Sum(Alt(AMOUNT_APPLIED,0)))/1000

  

33
0
60
10,571
23
86
512
2,827
1,339

but if I change it to

sum(alt(AMOUNT_DUE_REMAINING,0))-Sum(Alt(AMOUNT_APPLIED,0))/1000

I get these  figures which are great because the zero figure on the second row is correct, although the rounding is missing on all figures. I have tried the round function but still the same values.

  

32,526
-117
59,925
10,571,403
22,975
85,759
512,471
2,827,071
1,338,635

Thanks much appreciated in advance.

Tags (1)
10 Replies
MVP
MVP

Re: Expression returning -0

Provide sample data to check..

sasiparupudi1
Honored Contributor III

Re: Expression returning -0

Both of your expressions look same?

qlikmpate0
Contributor II

Re: Expression returning -0

The brackets are in different places

(sum(alt(AMOUNT_DUE_REMAINING,0))-Sum(Alt(AMOUNT_APPLIED,0)))/1000

VS

sum(alt(AMOUNT_DUE_REMAINING,0))-Sum(Alt(AMOUNT_APPLIED,0))/1000


qlikmpate0
Contributor II

Re: Expression returning -0

the data is part of a complex model and I cannot due to company policy also not too sure how to extract correctly for you to check.

sasiparupudi1
Honored Contributor III

Re: Expression returning -0

What is the expected output? the second table?

Re: Expression returning -0

I think in your first expression you are dividing the subtraction of two expression by a 1000

(Expression1 - Expression2)/1000

and in expression 2, you are dividing just the expression2 by 100

Expression - (Expression/1000)

Now, I am not sure what you are trying to do... do you mind explaining what the goal is?

qlikmpate0
Contributor II

Re: Expression returning -0

the goal is to have the output like this

33
-117
60
10,571
23
86
512
2,827
1,339
MVP
MVP

Re: Expression returning -0

LOL... without knowing your data, how we can give you same output..???

Re: Expression returning -0

Try this may be

If(

     (Sum(AMOUNT_DUE_REMAINING) - Sum(AMOUNT_APPLIED))/1000 = 0,

     -Sum(AMOUNT_APPLIED)/1000,

     (Sum(AMOUNT_DUE_REMAINING) - Sum(AMOUNT_APPLIED))/1000

)