Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Not applicable

Conditional variable

Hi,

is it possible to create a variable that has two possible outcome?.

For example, I want this statement to be held by one variable:

if OPEN_DATE ('DD/MM/YYYY') <  '01/06/2007' then A otherwise B

if not what could be the best way to go about this rather than created a field on the script?

1 Solution

Accepted Solutions
Partner
Partner

Re: Conditional variable

You could add a paramter to your variable.

Assign this to your variable:

If( Max($1) < '01/06/2007' ,'A','B')


calling the variable like:

$(vCheckDate(OPEN_DATE))

or

$(vCheckDate(CLOSE_DATE))

and so forth


in case you want to calculate it row-based don't keep the equal sign, otherwise keep it in the variable

hope this helps

Patrick


View solution in original post

3 Replies

Re: Conditional variable

You can assign a formula to a variable, e.g.

=If( Max(OPEN_DATE) < '01/06/2007' ,'A','B')

(This assumes that OPEN_DATE has 'DD/MM/YYYY' as format and that the default format is the same).

Just make sure that the variable definition starts with an equals sign. See The Magic of Variables

HIC

Highlighted
admin1
New Contributor III

Re: Conditional variable

Hi,

The issue in making it a filed in the table (your method) is I will have to use it 4 times from 3 difference sources. therefore I have to 'rename' this field 4 times rather than calling it once.

Hence I want to know is the way of making it a variable with two possible outcomes rather

Partner
Partner

Re: Conditional variable

You could add a paramter to your variable.

Assign this to your variable:

If( Max($1) < '01/06/2007' ,'A','B')


calling the variable like:

$(vCheckDate(OPEN_DATE))

or

$(vCheckDate(CLOSE_DATE))

and so forth


in case you want to calculate it row-based don't keep the equal sign, otherwise keep it in the variable

hope this helps

Patrick


View solution in original post