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: 
Not applicable

multiple logic OR in if statement does not return correct value

hello I am new to the Qlikview.  I have a button in Qlikview, I want to show the total headcount.  I used the following formula in Text Object Properties:

=sum({1} if(([Department]='A' or [Department]='B' or [Department]='C' or [Department]='D'), [Headcount])).

This formula only return sum of departments A and B.  It did not include headcounts of department C and D.  Can anyone let meknow what is the problem with my formula?

Thank you.

1 Solution

Accepted Solutions
swuehl
MVP
MVP

I can't see anything wrong with your syntax. Have you checked that

=sum({1} if([Department]='D', [Headcount]))

=sum({1} if([Department]='D', [Headcount]))

return correct results?

I assume that your departments are not called A,B,C,D so please check the correct spelling / case between your literals in your if() statement and your Department field values.

Could you post some sample data / qvw file?

Regards,

Stefan


View solution in original post

5 Replies
swuehl
MVP
MVP

I can't see anything wrong with your syntax. Have you checked that

=sum({1} if([Department]='D', [Headcount]))

=sum({1} if([Department]='D', [Headcount]))

return correct results?

I assume that your departments are not called A,B,C,D so please check the correct spelling / case between your literals in your if() statement and your Department field values.

Could you post some sample data / qvw file?

Regards,

Stefan


montero91
Creator
Creator

hi still,

I hope Iunderstand you, why do not you use:

=count({1<Department={'A','B','C','D'}>} Headcount)

Not applicable
Author

Hello, Stefan,

Thank you for your reply.  I figured it out.  I am working on an exiting Qlikview report and try to find out why the numbers do not match with the original dataset. Following your instruction, i went to check the department names, and they are all correct.  But when I was checking the spellings, I found out that the field name was wrong.  In the original data set, it has department and subdepartment, somehow, the formula were written as Department='A' or Department='B' or Subdepartment='c' etc.

Now I have corrected and got the correct answer. 

Thank you very much.

Not applicable
Author

Hi, Montero,

Thanks for your reply.  Here, I could not use count because some person has 0.5 haedcount in one department and 0.5 in another.

Anonymous
Not applicable
Author

Great discussion guys- I'm moving this over to the development area so you can get more visibility. @stillwater-thanks for marking as helpful and answered as it helps the other members receive points for assisting you.