Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Trouble with If Statement

Getting an odd result working with an If statement combined with Match.

Basically trying to determine if a variable includes a specific string, then perform a calulation depending on whether the specific string is there or not.

If(wildmatch(vVariable,'abc'), sum(field1)+((sum(field2)-sum(field3)),sum(field4)+((sum(field5)-sum(field6))


what I'm experiencing is it will not perform the calculation when the variable does not contain 'abc'.  I know the calculations work as I have done them separately.  I've noticed this works fine if I remove the addition (the bold part).  Can I not do addition with If statement?

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I figured it out.  It actually had to do with a string function issue (that I did not include in my post as I didnt think that was the issue).  Thanks

View solution in original post

2 Replies
Anil_Babu_Samineni

When you remove bold part you mention it is working, So that mean your condition may like below

If(wildmatch(vVariable,'abc'), sum(field1),sum(field4))


So, Then What if you use something like below

If(wildmatch(vVariable,'abc'), sum(field2)-sum(field3),sum(field5)-sum(field6))


Finally, You have extra parenthesis in your expression where i assume, I would ask you to try this, May be

If(wildmatch(vVariable,'abc'), sum(field1)+((sum(field2)-sum(field3)),sum(field4)+((sum(field5)-sum(field6))


Instead of above one please use this - I removed and added one more red colour parenthesis("(" and ")") only

If(wildmatch(vVariable,'abc'), sum(field1)+(sum(field2)-sum(field3)),sum(field4)+(sum(field5)-sum(field6)))


Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

I figured it out.  It actually had to do with a string function issue (that I did not include in my post as I didnt think that was the issue).  Thanks