Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikuser222
Creator
Creator

Help with Match function in if condition?

Hi Everyone,

Can you please help me to figure out what is wrong with below if condition?

Somehow its not giving expected results.

if(Type = 'XXX',if(Root <> 'Total', if(Match (Category,'8','1','2','33','35','3') and match(subtype,'20','21','23','20') ,

if([Date] >= IntialDate and [Date]<=FinalDate and [Amount] >= InitialAmt and [Amount] <= FinalAmt , [Amount] * YYY , if(Type = 'XXX',if(Root = 'Total' , if([Date] >= IntialDate and [Date]<=FinalDate and [Amount] >= InitialAmt and [Amount] <= FinalAmt, [Amount] * YYY))))))  as AAAA

Thanks

8 Replies
cdecluseau
Contributor III
Contributor III

Hello,

Perhaps because there's any final ")" for your multiple "if" ?

Digvijay_Singh

Looks like few conditions are duplicated and doesn't make sense, as cdecluseau mentioned, one last ')' is missing.

Doesn't it look like this when remove duplicated condtions -

if(Type = 'XXX',

if(Root <> 'Total',

    if(Match (Category,'8','1','2','33','35','3') and match(subtype,'20','21','23','20') ,


if([Date] >= IntialDate and [Date]<=FinalDate and [Amount] >= InitialAmt and [Amount] <= FinalAmt ,

            [Amount] * YYY 

           

             )

         )

      )

    )  as AAAA

swuehl
MVP
MVP

Yes, it's seems there is a closing parenthesis missing.

Besides this, it seems that your second condition based on Root = 'Total' can't evaluate to True, because it's in the THEN branch for your first condition Root <> 'Total':

if(Type = 'XXX',

    if(Root <> 'Total',

        if(Match (Category,'8','1','2','33','35','3') and match(subtype,'20','21','23','20'),

              if([Date] >= IntialDate and [Date]<=FinalDate and [Amount] >= InitialAmt and [Amount] <= FinalAmt ,

                   [Amount] * YYY ,

                   if(Type = 'XXX',

                        if(Root = 'Total' ,

                             if([Date] >= IntialDate and [Date]<=FinalDate and [Amount] >= InitialAmt and [Amount] <= FinalAmt,

                                  [Amount] * YYY

                                  )

                             )

                        )

                   )

              )

         )

   ) /*missing Parenthesis added */  as AAAA

qlikuser222
Creator
Creator
Author

Thanks for reply.

Unfortunately still not getting expected results. Any alternative to if condition there?

Thanks

swuehl
MVP
MVP

Well, without knowing what you want to achieve (AKA 'expected results' in combination with input values), it's hard to help without guessing around.

qlikuser222
Creator
Creator
Author

Hi,

Please find attached  to the main question .It   has example data in the script.

Thanks

swuehl
MVP
MVP

Still not sure what you are trying to achieve.

Your Amt1 values does not match in the intervals given by InitialAmt and FinalAmt in your Calc table, that's why you don't get any Disc1 results.

swuehl
MVP
MVP

Also take care to use an appropriate Date Format, so your date values show a numeric representation and you can use > or < for comparison.

I've changed some of your input Amt1 values to get the comparison with your limits working and guessed around what you might want to do.

Attached a sample that delivers something.