Qlik Community

Ask a Question

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Do More with Qlik - for Beginners and Beyond, Topic: Qlik Replicate on January 21, 2PM EST. REGISTER 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
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
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

Creator
Creator

hi still,

I hope Iunderstand you, why do not you use:

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

Not applicable

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

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

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.