Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

qlikuser222
Contributor

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
New Contributor III

Re: Help with Match function in if condition?

Hello,

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

Digvijay_Singh
Honored Contributor III

Re: Help with Match function in if condition?

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

MVP
MVP

Re: Help with Match function in if condition?

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
Contributor

Re: Help with Match function in if condition?

Thanks for reply.

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

Thanks

MVP
MVP

Re: Help with Match function in if condition?

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
Contributor

Re: Help with Match function in if condition?

Hi,

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

Thanks

MVP
MVP

Re: Help with Match function in if condition?

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.

MVP
MVP

Re: Help with Match function in if condition?

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.