Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Nested If statements - Sum if

Hello the community,

I am trying to write a nested if statement with 2 different fields of data.

One field is called HOURS, the other is called FUNCTION

Basically I want the sum of 'regular' hours of a specific function.

I can't tell where my error is...

 

=Sum(if(([FUNCTION]='ABC' and HOURS='Regular'), HOURS))

OR

=Sum(if(([FUNCTION]='ABC' and HOURS='Overtime'), HOURS))

If you have any idea....

Thank you

Labels (1)
1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

Why don't you use set analysis here?

=Sum({<FUNCTION = {'ABC'}, HOURS = {'Regular'}>} HOURS)

=Sum({<FUNCTION = {'ABC'}, HOURS = {'Overtime'}>} HOURS)

View solution in original post

4 Replies
sunny_talwar
MVP
MVP

Why don't you use set analysis here?

=Sum({<FUNCTION = {'ABC'}, HOURS = {'Regular'}>} HOURS)

=Sum({<FUNCTION = {'ABC'}, HOURS = {'Overtime'}>} HOURS)

Not applicable
Author

Agree with sunindia that set analysis is the way to go, but I have to ask:

What you are expecting the sum(HOURS) to evaluate to if this field contains the string values of 'Regular' and 'Overtime'?

Not applicable
Author

I thought I tried that earlier, I guess I forgot something...

It works now, Thank you sunindia

sunny_talwar
MVP
MVP

No problem, we are here to help always

Best,

Sunny