Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
nenadvukovic
Creator III
Creator 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
its_anandrjs
Champion III
Champion III

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.



View solution in original post

7 Replies
Anil_Babu_Samineni

Try this?

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

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
its_anandrjs
Champion III
Champion III

You have to write this

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

nenadvukovic
Creator III
Creator III
Author

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

nenadvukovic
Creator III
Creator III
Author

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?

Anil_Babu_Samineni

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

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
its_anandrjs
Champion III
Champion III

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
Creator III
Creator III
Author

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

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