Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using CASE in load

Hi,

I want to use the below SQL code in the load , how i can do this :

  SELECT SUM(CASE WHEN ORG_ID IN(658,657,661,678,663,659,662,660)

  THEN SUM (GSV - DISCOUNT)

  ELSE SUM (GSV) END) Value

    FROM TABLE;

I've tried the below in my qlik load , but don't know how to pass multiple values for ORG_ID :

If ( ORG_ID=(658) ,GSV-DISCOUNT ,GSV ) as  Value ,

Regards,

Adil

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi Adil,

One way of handling that is using Match()

If(Match(ORG, 658, 657, 661, 678) > 0, GSV - DISCOUNT, GSV) AS Value

If values are literals instead of numbers, use single quotes to separate them

If(Match(ORG, 'AA', 'BB', 'CC', 'DD') > 0, GSV - DISCOUNT, GSV) AS Value

Miguel

View solution in original post

1 Reply
Miguel_Angel_Baeyens

Hi Adil,

One way of handling that is using Match()

If(Match(ORG, 658, 657, 661, 678) > 0, GSV - DISCOUNT, GSV) AS Value

If values are literals instead of numbers, use single quotes to separate them

If(Match(ORG, 'AA', 'BB', 'CC', 'DD') > 0, GSV - DISCOUNT, GSV) AS Value

Miguel