Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Not applicable

Multiple comparison using variable

Hi,

I am having 12 variables - var1 , var2 , var3, ... , var12 . I would like to compare these variables like var1 = var2 = var3 = ... = var12 . How can we achieve this in QlikView ? Is there any in-built function ?

Best Regards,

Arun.

Tags (1)
1 Solution

Accepted Solutions
Not applicable

Re: Re: Multiple comparison using variable

Hi,

See attached QVW, there are 2 examples: with If and usin SubStringCount.

The first is a common Sequence IF compare fisrt variable VS the rest of variables.

She Second use a variable with a concatenation of vVar2 to vVar12 then using SubStringCount() Function create a comparission using and if. (If all variables are same than the first variable function return 11).

Best regards and sorry  for my English Smiley Frustrated

10 Replies

Re: Multiple comparison using variable

Create another variable in UI by click Ctrl+Alt+V for Variable overview and there create a variable and write the expression for variable.

Not applicable

Re: Multiple comparison using variable

Hi Anand,

In that case many variables needs to be created. Right ?

Eg:

var1 = 'FY13-Q1'

var2 = 'FY13-Q2'

var3 = 'FY13-Q3'

.

.

var12 = 'FY12-Q1'

I would like to compare all variables like var1 = var2 = var3 = ... = var12 .

Best Regards,

Arun.

sorrakis01
Valued Contributor

Re: Multiple comparison using variable

Hi,

Why don't use the secuence IF?

Cy

Not applicable

Re: Multiple comparison using variable

Hi Jordi,

I don't know about Sequence IF. Could you please provide an example ?

Best Regards,

Arun.

Not applicable

Re: Multiple comparison using variable

Hi Arun, what's the expected output of the comparison?

Not applicable

Re: Multiple comparison using variable

Hi Chander,

If all values are same then 'Valid'.

If all are different, then 'Invalid'

Not applicable

Re: Multiple comparison using variable

Jordi's solution comes to my mind as well. Am not aware of a more elegant solution. Try the following

If( v1 = v2 and v2 = v3 and v3 = v4 and v4 = v5 and v5 = v6 and v6=v7 and v7=v8 and v8 = v9 and v9=v10 and v10 = v11 and v11 = v12, 'Valid', 'Not valid')

you will need to use variable or $(variable) depending on how you have defined your variables.

Not applicable

Re: Re: Multiple comparison using variable

Hi,

See attached QVW, there are 2 examples: with If and usin SubStringCount.

The first is a common Sequence IF compare fisrt variable VS the rest of variables.

She Second use a variable with a concatenation of vVar2 to vVar12 then using SubStringCount() Function create a comparission using and if. (If all variables are same than the first variable function return 11).

Best regards and sorry  for my English Smiley Frustrated

Not applicable

Re: Multiple comparison using variable

Oswaldo, the concatenation followed by substringcount alternative was brilliant.

Community Browser