Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to use if statement in chart expression

Hi all,

I need to use IF statement in an expression  for a standard chart; I'm explaining with an example.

I have a table like this:

PK
FK
value
1110
2115
329
438
5312

User may select (or not) a set of data with different values for FK and cannot select FK values, but the chart has to create an expression like this:

Show the trend of values having FK = 2.

I may consider to implement a second line with a different FK value, and compare it with the first one.

I already used an expression like this:

If(value > genericVar, value, Null())

it seems it works very well.

If(FK = 2, value, Null())

it seems it doesn't work very well - how to do?

Count(If(FK = 2, value, Null()))

it seems it works very well.

Thank you

19 Replies
Not applicable
Author

yes

Not applicable
Author

Your example it's ok, what is the problem? Take attenction that 0 it't different to null()

Not applicable
Author

Tried to use 'AA01' instead 1 and 'AA02' instead 2: the chart doesn't work.

The expressions If(status = 'AA01', QTA, 0) and If(status = 'AA02', QTA, 0) always return 0: the lines are fully 0...

This is my problem.

Not applicable
Author

In example Test.qvw I can't see status='AA01' or 'AA02', I see only 1 and 0002 .

Not applicable
Author

That's an old example. After that post I tried to use new set of data (with AA01 and AA02) and now it works. My real document doesn't want to compare a column with a string 😕 dunno why.

Not applicable
Author

Your example it's ok, it works. Try to post a screenshot where we can see the column with data and the chart expression 

Not applicable
Author

I already changed my document some weekes ago making a table per status, but I thought that was not a good solution and QlikView must do a string compare in expression... So I wrote here.

The example is similar to my document, the problem is not only referring to a document, but I just need to know how to do in general.

Not applicable
Author

...How can I get a substring?

Davidoff
Contributor III
Contributor III

=IF( Left(Examplestring,5) = 'Hello', Thenaction, Elseaction)

Not applicable
Author

Thank you all for your answers ^^