# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

## color in table based on variable

how can you color   have multiple colors when using the Background color expression?

Below is what I am trying with no luck.

if(ActPkgCost/PurchPackSz<0.25, green(),

if(ActPkgCost/PurchPackSz>0.25, <0.50 Yellow(),

if(ActPkgCost/PurchPackSz>0.50, Red())))

1 Solution

Accepted Solutions
MVP

## Re: color in table based on variable

Try this

If(ActPkgCost/PurchPackSz < 0.25, Green(),

If(ActPkgCost/PurchPackSz < 0.50, Yellow(),

If(ActPkgCost/PurchPackSz > 0.50, Red())))

5 Replies
MVP

## Re: color in table based on variable

Try this

If(ActPkgCost/PurchPackSz < 0.25, Green(),

If(ActPkgCost/PurchPackSz < 0.50, Yellow(),

If(ActPkgCost/PurchPackSz > 0.50, Red())))

Contributor

## Re: color in table based on variable

Hi Sunny -

Is yours (above) missing a comma just before Yellow()  - I included the comma below

If(ActPkgCost/PurchPackSz < 0.25, Green(),

If(ActPkgCost/PurchPackSz < 0.50, Yellow(),

If(ActPkgCost/PurchPackSz > 0.50, Red())))

color in table based on variable

MVP

## Re: color in table based on variable

I did

Esteemed Contributor III

## Re: color in table based on variable

OK, if we're speaking of improvements...

If(ActPkgCost/PurchPackSz < 0.25, Green(),

If(ActPkgCost/PurchPackSz < 0.50, Yellow(),

Red()))

Contributor

## Re: color in table based on variable

try Sunny's or try this with your original

if(ActPkgCost/PurchPackSz<0.25, green(),

if(ActPkgCost/PurchPackSz >= 0.25 and ActPkgCost/PurchPackSz < 0.50, Yellow(),

if(ActPkgCost/PurchPackSz >= 0.50, Red())))