Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

convert case statement in qliksense

Hi All,

I have a case statement which I need to convert it to Qlik Script.

                case  when
    ServiceChartField  = '0000'
                                                then
                                                                case 
                                                                                when Model             like '%Accessories%'     then 'Accessories'
                                                                                when Model              like '%Licenses%'           then 'Licenses'
                                                                                when SubModel      like '%Software%'          then 'Software'
                                                                else
                                                                                'System'
                                                                end 
                                                else 'Service'
                end

Can you guys help me in writing the script.

So far I have got this, not sure if its correct:

if(wildmatch([Model], '*Accessories*' ),'Accessories',

    if(wildmatch([Model], '*Licenses*' ), 'Licenses',

    if(wildmatch([SubModel], '*Software*') ,'Software' ,

    if(wildmatch([SubModel], '*System*') ,'System' ,

    if(wildmatch([SubModel], '*Service*') ,'Service' ,)

  

    ))))

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

I think this an accurate conversion of the CASE statement:

If(ServiceChartField = '0000',

  If(Model like '*Accessories*', 'Accessories',

  If(Model like '*Licenses*', 'Licenses',

  If(SubModel like '*Software*', 'Software',

  'System'))),

  'Service'

)


I prefer Like to WildMatch for a single comparison as it makes for more readable code

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

1 Reply
jonathandienst
Partner - Champion III
Partner - Champion III

I think this an accurate conversion of the CASE statement:

If(ServiceChartField = '0000',

  If(Model like '*Accessories*', 'Accessories',

  If(Model like '*Licenses*', 'Licenses',

  If(SubModel like '*Software*', 'Software',

  'System'))),

  'Service'

)


I prefer Like to WildMatch for a single comparison as it makes for more readable code

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein