Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

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

Tags (1)
19 Replies
Not applicable

how to use if statement in chart expression

Try with ='2'

Not applicable

Re: how to use if statement in chart expression

Try

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

or

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

jagannalla
Valued Contributor III

Re: how to use if statement in chart expression

Can you tell me little bit more.. Show any output with example. what you want according to your data?

what is the dimension?

What is the result you want?

Not applicable

Re: how to use if statement in chart expression

Use the first table, then the expression has to use values with FK = 2; the chart result must be:

test.png

when the user will select FK <> 2, then the chart cannot show any data.

Not applicable

Re: how to use if statement in chart expression

I tried FK = '2', but it still seems it doesn't work.

Do "If(FK = 2, sum(value), Null())" and "If(FK = 2, max(value), Null())" modify the value of record?

jagannalla
Valued Contributor III

Re: how to use if statement in chart expression

Do you want this result means..

Just goto properites -> presentation tab -> uncheck suppress zero values.

- if not please explain clearly what you want step by step.

MVP
MVP

how to use if statement in chart expression

Try this,

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


Just goto properites -> presentation tab -> uncheck suppress zero values.

Hope this helps you.  If it not works can you attach sample file.

Regards,

Jagan.

Not applicable

Re: how to use if statement in chart expression

mmm I tried with an example and expressions now work as well...

Maybe a bug in my expression...?

You can see an example (see attachment)...

Not applicable

how to use if statement in chart expression

Another question.

If works with number: If ([var] = 1, <do this>, <else do this other>);

How does it work with string? Can I do this If ([var] = 'var', <do this>, <else do this other>)?

Thank you

Community Browser