Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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?

1 Solution

Accepted Solutions
hector
Specialist
Specialist

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

View solution in original post

5 Replies
erichshiino
Partner - Master
Partner - Master

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)

hector
Specialist
Specialist

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

Not applicable
Author

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.

joancasellasvega
Partner - Contributor III
Partner - Contributor III

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

VamsiKrishna05
Contributor
Contributor

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.