Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

nenadvukovic
Contributor III

Inconsistent behavior in in-table calculations

Hello,

Does anyone have an idea of why would this expression results with different results?

if("Balance" - "Safety Stock" < "Safety Stock", "Balance" - "Safety Stock", 0)

Items marked in yellow are expected to show 0 in the last column:

2017-09-04_11-19-41.png

Thanks

1 Solution

Accepted Solutions

Re: Inconsistent behavior in in-table calculations

For 4th row values after your condition

1. Step

"Balance" - "Safety Stock" 

    38168   -  27000   = 11168


2. Step

"Balance" - "Safety Stock" < "Safety Stock"

                                11168 < 27000

This statement is true so for this true part of the statement execute


That is "Balance" - "Safety Stock"

Then why you expecting 0 let me know.



7 Replies

Re: Inconsistent behavior in in-table calculations

Try this?

if(("Balance" - "Safety Stock") < "Safety Stock", ("Balance" - "Safety Stock"), 0)

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

Re: Inconsistent behavior in in-table calculations

You have to write this

if("Balance" - "Safety Stock" < "Safety Stock", 0,  "Balance" - "Safety Stock")

nenadvukovic
Contributor III

Re: Inconsistent behavior in in-table calculations

Thx, but I tried that before posting the question. Just one detail, those are not field names but column labels.

nenadvukovic
Contributor III

Re: Inconsistent behavior in in-table calculations

No, that does not work. I want to show red lines with actual numbers, and others with 0. If you look my screenshot you would see that lines 1 and 2 are fine, but lines 4, 7, 8, 10 are not. How come?

Re: Inconsistent behavior in in-table calculations

Can you attach inline because i just tested and it's working.. I am not sure Where you made mistake. Are you doing this in script / UI ??

If UI, Try this? May be

if((Balance - [Safety Stock]) < [Safety Stock], (Balance - [Safety Stock]), 0)

This should work as i feel, But if number format issue, You could define Num() .. over expression

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

Re: Inconsistent behavior in in-table calculations

For 4th row values after your condition

1. Step

"Balance" - "Safety Stock" 

    38168   -  27000   = 11168


2. Step

"Balance" - "Safety Stock" < "Safety Stock"

                                11168 < 27000

This statement is true so for this true part of the statement execute


That is "Balance" - "Safety Stock"

Then why you expecting 0 let me know.



nenadvukovic
Contributor III

Re: Inconsistent behavior in in-table calculations

I apologize, it is consistent with the expression used. My mistake.

Thanks for your time. I'll mark all your replies helpful.