Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Replace Multiple If Statements

Hi all,

Quick one. I have multiple nested ifs statement, say about 20 statements. I do realise that I shouldn't have that many if statements, so really looking for a better way.

QlikView seems to recognise the first 10 or so statements and then doesn't recognise the other statements.

Is there a way to rewrite this or an alternative to get this to work?

Any help will be appreciated.

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Like:

Pick(Match(Field, Value1, Value2, ...) , Result1, Result2, ...)

View solution in original post

13 Replies
tresesco
MVP
MVP

Like:

Pick(Match(Field, Value1, Value2, ...) , Result1, Result2, ...)

Not applicable
Author

Thanks Tresesco.

Even with the pick(match), it still stops at the 11th value. Any other ideas?


tresesco
MVP
MVP

I never heard of this limitation. And after testing in an app, it does confirm otherwise. Please check the sample qvw. I tried till 12th level - and worked fine.

jagannalla
Partner - Specialist III
Partner - Specialist III

Hi,

Pick works for 'n' number of conditions.

For eg:

LOAD

RowNo() as R

AutoGenerate 20;

Take St. table with dimension as R

and expr as

Pick(

Match(R,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20),

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)

Thanks,

Jagan

Not applicable
Author

Razor,

What does your massive If statement do?  Can you post it?

There are options,

  • You could link to another data set to match values.
  • You could use wildmatch()  if you are pattern matching

  • Create your own function to take in one value, process it more linearly and return a value.

Example of my situation cut down.

join (data) load Tick_no,wildmatch(Description,
'*filesystem is now*',
'Error(s) written to /var/adm/messages *',
'The Qlikview Server service terminated unexpectedly.*',
'Possible performance problem*',
'*java.lang.OutOfMemoryError. Restart*',

'* has hung threads. Contact *' ) as Pattern_match resident data;


LOAD * INLINE [
    Pattern_match, Pattern Description
    0, N/A
    1, filesystem full
    2, Var/ADM messages
    3, Qlikview service Terminated
    4, Performance Alert
    5, Java OOM
    6, Webserver server down or hung
    ];

My application has 30+ lines in the table.

Richard

Not applicable
Author

Match()

WildMatch()

MixMatch()

Not applicable
Author

Thanks for all the responses so far.

I have included a sample of my if and pick match expressions that stop after the 10th or 11th option

if(Col1 ='Chart1', 'Chart1',

            if(View ='Chart2', 'Chart2',

                  if(View ='Chart3', 'Chart3',

                        if(View ='Chart4', 'Chart4',

                               if(View ='Chart5', 'Chart5',

                                     if(View ='Chart6', 'Chart6',

                                           if(View ='Chart7', 'Chart7',

                                                 if(View ='Chart8', 'Chart8',

                                                       if(View ='Chart9', 'Chart9',

                                                             if(View ='Chart10', 'Chart10',

                                                                   if(View ='Chart11', 'Chart11',

                                                                         if(View ='Chart12', 'Chart12',

                                                                               if(View ='Chart13', 'Chart13',

                                                                                      if(View ='Chart14', 'Chart14',

                                                                                              if(View ='Chart15', 'Chart15'

                                                                                                                                     )))))))))))))))

                                                                                                                                                                                                                                                   

Pick(Match(View, 'Chart1','Chart2',   'Chart3',  'Chart4',  'Chart5', 'Chart6',  'Chart7',   'Chart8',  'Chart9', 'Chart10', 'Chart11', 'Chart12', 'Chart13', 'Chart14', 'Chart15', 'Chart16', 'Chart17') ,

                         'Chart1','Chart2',  'Chart3',  'Chart4',  'Chart5', 'Chart6',  'Chart7',  'Chart8',  'Chart9',  'Chart10', 'Chart11', 'Chart12', 'Chart13', 'Chart14', 'Chart15', 'Chart16', 'Chart17')  as Test_Col1

Not applicable
Author

Thanks,


Wow.  Can you explain what you are trying to do? Is this function on a "Calculation Condition" to display a chart only when conditions are met.

There may be a better way.

Richard

Not applicable
Author

Ignore the labels I used, they are just for illustration.

What I am trying to do is to create a list in my script that I can use as a dropdown list in my front end, so users can navigate from page to page in a neat and tidy way.

Works fine for the frist 10 or 11, but not after it