How do I create a QlikView expression which loops through the values, modifying the background cell colour ?

Hi,

I have a pivot table object in my QlikView application which sets the background colour of a column's cell according to its value.

The object checks the value of a field (Status_ID) and then sets the colour depending on the value of another field (SPI Status). The idea behind this method is that I can 'customise' the values to be checked against, for each column. The example below shows what I mean - the values checked against are held in two fields, Upper_Threshold and Lower_Threshold.

If (Status_ID = 'SS001',
   If ([SPI Status] >= Upper_Threshold, RGB(255,0,0),
     If ([SPI Status] >= Lower_Threshold, RGB(255,128,0),Green()))
,If (Status_ID = 'SS002',
   If ([SPI Status] >= Upper_Threshold, RGB(255,0,0),
     If ([SPI Status] >= Lower_Threshold, RGB(255,128,0),Green()))
,If (Status_ID = 'SS003',
   If ([SPI Status] >= Upper_Threshold, RGB(255,0,0),
     If ([SPI Status] >= Lower_Threshold, RGB(255,128,0),Green()))
,If (Status_ID = 'SS004',
   If ([SPI Status] >= Upper_Threshold, RGB(255,0,0),
     If ([SPI Status] >= Lower_Threshold, RGB(255,128,0),Green()))

However, as there are 30 Status IDs this has resulted in a huge multi-IF statement. I would like to reduce this code to a loop using a variable for the Status ID values.

How would I go about coding this ? How do I declare a local variable in my expression ? Or do I set it up outside my expression ?

Thanks
Toco
TocogroupAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobOwner (Aidellio)Commented:
Are they all going to be the same?

why not just:

If ([SPI Status] >= Upper_Threshold, RGB(255,0,0),If ([SPI Status] >= Lower_Threshold, RGB(255,128,0),Green()))
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TocogroupAuthor Commented:
Hah yes. Couldn't see the wood for the trees.
Thanks for that. Works great.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.