
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to Write a Simple IF Statement
I need to write a simple IF statement that says if the calculated value is negative, then display the value as 0. Otherwise complete the expression. In Excel, the if statement would look something like this:
if A>B,A-B,0
How would I create this in QlikView?
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, to avoid the if(), you can use range functions like rangemax
Ex.
rangemax(A-B,0)
So, if A-B > 0, the result will be (A-B), else if the result is negative, the result will be 0
Rgds


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From the help:
if( condition , then , else )
The three parameters condition, then and else are all expressions. The first one, condition, is interpreted logically. The two other ones, then and else, can be of any type. They should preferably be of the same type. If condition is true, the function returns the value of the expression then. If condition is false, the function returns the value of the expression else.
Example:
if( Amount>= 0, 'OK', 'Alarm' )
In your case
=if( Amount>= 0, Amount, 0)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, to avoid the if(), you can use range functions like rangemax
Ex.
rangemax(A-B,0)
So, if A-B > 0, the result will be (A-B), else if the result is negative, the result will be 0
Rgds

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
These answers were each helpful in different situations. Thank you SO much for taking the time to point me in the right direction. I'll be bookmarking this thread for sure.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm trying to create the following dimension and is not working
=If(count( distinct if( INSTANCIA > 0 , [LastModified.autoCalendar.Date]))>4,'Yes','No')
any suggestion?
Thanks in advance,
Joan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Everyone,
Need help i need to write if condition,
I want to display attribute values where the attribute name = target_skill_MI.
Can anyone help me with the exception.
where ever the target_skill_MI is there i want to replace with attribute values remaining data should not change only this target_skill_MI need to change.
