Qlik Sense App Development

Contributor

Help with Match function in if condition?

Hi Everyone,

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

Tags (4)
8 Replies
New Contributor III

Re: Help with Match function in if condition?

Hello,

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

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

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

Contributor

Re: Help with Match function in if condition?

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

Thanks

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.

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

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

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.