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: 
Not applicable

Comparing Two Values to get the difference

Hello,

I'm trying to compare two values in an expression and get the difference but I don't want a negative number. Is there anyway to formulate this WITHOUT an If statement>???

Example: I'm comparing The Book quantitiy of several items and the counted quantity. I want a new field that is the difference between the two and is always a positive number.

3 Replies
prieper
Master II
Master II

Give it a try with (A>B)*(A-B)
should end with 0 for negative differences.

HTH
Peter

Not applicable
Author

Hello, I apologize for not being clear in my original post. I am looking for the variation between the two numbers, I do not want any values to be changed to zeros.

For example if the book quantity is 20 and the counted quantity is 30 I want it to produce the number 10

and if the book quantity is 20 and the counted quantity is 10 I want it to produce the number 10 also.

I was wondering if this is possible without an If statement? Thank you for your help.

Not applicable
Author

You can use the function fabs( ) to get the absolute value, always positive.