8 Replies Latest reply: Nov 29, 2015 9:28 AM by Asaf Meiri RSS

    CASE statement in QlikView

      Hi,

       

      I was wondering if anyone would be able to help me.  I want to create the following Case statement in QlikView:

       

      CASE WHEN [Account Name] IN ('Hong Kong') THEN 'HK'

      WHEN [Account Name] IN ('USA') THEN 'NY'

      WHEN [Account Name] IN ('UK') THEN 'LDN'

      ELSE 'OTHER'

      END

       

      Is this possible to do within QlikView?

       

      Any help would be greatly appreciated.

       

      Many thanks.

       

      Rajiv.

        • Re: CASE statement in QlikView

          if(wildmatch([Account Name],'*Hong Kong*', 'HK',

          if(wildmatch([Account Name],'*USA*', 'NY',

          if(wildmatch([Account Name],'*UK*','LDN',

          'OTHER')))

           

           

          Wildmatch works if you need any string with the resulting '*string*' in it. If you are looking for exact match then just match(field,'String') will work too

          • Re: CASE statement in QlikView
            kalyan satya

            case

            when saleschannel='Online' and (userid is null  or userid not like '%RB:MOBILE%')  then 'ONLINE WEB SALES'

            when saleschannel=online and userid like '%RB:MOBILE%' then 'MOBILE'

            when userid like '%RB:MOBILE%'  and userid not in ('RB:MOBILEWINDOWASAPP','RB:MOBILEADRIODAPP')  then 'WAP SALES'

            when userid like '%RB:MOBILE%'  and userid in ('RB:MOBILEWINDOWASAPP','RB:MOBILEADRIODAPP')  then  'APP SALES'

            when saleschannel='corporate' and bookingsource='corporate' then 'offline agents'

            when saleschannel='Corporate' and bookingsource='webdirect' then 'other offline agents'

            end as channel

             

             

            can you help out with this Query ..i am facing problem  in writing (in function)  and not like

              • Re: CASE statement in QlikView
                Dok Mbini

                Hi All,

                 

                I've been also struggling to convert this piece of code to Qlikview,

                Could I please get assistance:

                 

                CASE

                  when MAC_CODE = 963 then ''SNL''

                  Else ''MLOAN''

                END as PRODUCT_CODE

                 

                CASE

                     when REGISTRATION_MONTH_CODE = ''NOTREG''

                       then ''N''

                     else

                            CASE when ( year(INFORMATION_DATE)*100 + month(INFORMATION_DATE) )

                                      else ''N''

                            END as  REG_LAST_3MONTHS_IND

                 

                CASE

                          when FINAL_ML_AMT <= 50000   then  ''A''

                          when FINAL_ML_AMT <= 100000  then  ''B''

                          when FINAL_ML_AMT <= 150000  then  ''C''

                          when FINAL_ML_AMT <= 350000  then  ''D''

                          when FINAL_ML_AMT <= 700000  then  ''E''

                          else ''F''

                          END as MLOANS_BANDS_CODE

              • Re: CASE statement in QlikView
                Asaf Meiri

                fix:

                =if(wildmatch([Account Name],'*Hong Kong*'), 'HK', if(wildmatch([Account Name],'*USA*'), 'NY', if(wildmatch([Account Name],'*UK*'),'LDN', 'OTHER')))