Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
bruce_sorge
Contributor III
Contributor III

Nested IF Statement

Greeting Qlik community,

 

I have a simple if statement that works. It's:

=if([ABS_TYPE]='Centers',rgb(642,67,67),if([ABS_TYPE]='Grant',rgb(25,58,223),if([ABS_TYPE]='Fellow',rgb(0,204,0),if([ABS_TYPE]='SBIR',rgb(255,37,249)))))

What I want to do is add another if that, if the grant is a STAR grant, then the color of the point is Yellow. I tried this:

=if([ABS_TYPE]='Centers',rgb(642,67,67),if([ABS_TYPE]='Grant',rgb(25,58,223),if([ABS_TYPE]='Fellow',rgb(0,204,0),if([ABS_TYPE]='SBIR',rgb(255,37,249))))
if([STAR]='Y',rgb(255,255,51)))

I get the error that ) is expected. I know I have to put a comma between the two ifs, but not exaclty sure where it goes as when I put a comma, I get either the same error or the error that say "If takes 2-3 parameters.

 

Thanks

Bruce

1 Solution

Accepted Solutions
Anil_Babu_Samineni

You've placed quite wrong. Perhaps this?

=if([ABS_TYPE]='Centers',rgb(642,67,67),if([ABS_TYPE]='Grant',rgb(25,58,223),if([ABS_TYPE]='Fellow',rgb(0,204,0),if([ABS_TYPE]='SBIR',rgb(255,37,249),if([STAR]='Y',rgb(255,255,51))))))

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

View solution in original post

3 Replies
Anil_Babu_Samineni

You've placed quite wrong. Perhaps this?

=if([ABS_TYPE]='Centers',rgb(642,67,67),if([ABS_TYPE]='Grant',rgb(25,58,223),if([ABS_TYPE]='Fellow',rgb(0,204,0),if([ABS_TYPE]='SBIR',rgb(255,37,249),if([STAR]='Y',rgb(255,255,51))))))

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
bruce_sorge
Contributor III
Contributor III
Author

Thanks Anil, the expression checks OK, but I am not getting the yellow for the STAR if. I will try to figure out why that is.

Anil_Babu_Samineni

Qlik is Case sensitive when we are comparing. Else, There is no wrong in the statement.

=if([ABS_TYPE]='Centers',rgb(642,67,67),if([ABS_TYPE]='Grant',rgb(25,58,223),if([ABS_TYPE]='Fellow',rgb(0,204,0),if([ABS_TYPE]='SBIR',rgb(255,37,249),if([STAR]='y',rgb(255,255,51))))))

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