Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create two conditions in the "Edit Script "

Create two conditions in the "Edit Script " QlikView, example:

I created one that has only one condition and it worked right

IF (NUM ([COD. COMPANY]) = 11, 'COMPANY 1 '
      IF (NUM ([COD. COMPANY]) = 14, 'COMPANY 2'
      IF (NUM ([COD. COMPANY]) = 18 '
COMPANY 3 ',))) AS WORK

BRANCH

I wanted one with two conditions that would look like this phenomenon, is cod. company = 11 and
cod.branch = 517 then COMPANY 517

if anyone can help me.

thanks

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hello,

This syntax should work

If(Num([COD. COMPANY]) = 11 AND BRANCH = 517,

     517, // When condition is true

     If(Num([COD. COMPANY]) = 11 AND BRANCH = 518, // When condition is false, nest a new If()

          518,

          'Other')

) AS COMPANY

Anyway, depending on your data model there might be some easier solution, probably using mapping tables, joins and so. Having complex conditionals may perform really poor and it make the script to take longer to load.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

View solution in original post

5 Replies
kji
Employee
Employee

Looks to me like you need a comma at the end of the first 2 lines, and a value for when COD. COMPANY is not 11,14 or 18

Not applicable
Author

Try this:

IF (NUM ([COD. COMPANY]) = 11, 'COMPANY 1 '

      IF (NUM ([COD. COMPANY]) = 14, 'COMPANY 2'

      IF (NUM ([COD. COMPANY]) = 18 'COMPANY 3 ',

if(NUM ([COD. COMPANY]) = 11 and num(cod.branch) = 517 , 'COMPANY 517'

))) ) AS WORK



Miguel_Angel_Baeyens

Hello,

This syntax should work

If(Num([COD. COMPANY]) = 11 AND BRANCH = 517,

     517, // When condition is true

     If(Num([COD. COMPANY]) = 11 AND BRANCH = 518, // When condition is false, nest a new If()

          518,

          'Other')

) AS COMPANY

Anyway, depending on your data model there might be some easier solution, probably using mapping tables, joins and so. Having complex conditionals may perform really poor and it make the script to take longer to load.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

Not applicable
Author

Hello Johan, I need two conditions even

Not applicable
Author

Thanks to all who somehow tried to help me, it worked just fine Miguel.