Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
khanashique
Creator II
Creator II

Background Color Expression

Hi Experts,

I am trying to put background color expression as shown below,

scenario is if Balance is greater than Budget then RED else Green and if TDC element is "Sales" and Balance is greater than Budget then Green else RED. (TDC Element, Balance, Budget are column names)

if((Month = '1' and Balance > BudgetAmount and Period = '1', rgb(255,0,0), rgb(0,192,0)) OR

if(Month = '1' and TDC_Element = 'Sales' and Balance > BudgetAmount and Period = '1',rgb(0,192,0), rgb(255,0,0))


Have tried to use the above expression but hard luck it does not work.



Thanks,

MAK.

Labels (1)
18 Replies
Thiago_Justen_

Could you please share a mock up?

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago
jonathandienst
Partner - Champion III
Partner - Champion III

Try this:

if(Month = '1' and TDC_Element = 'Sales' and Balance > BudgetAmount and Period = '1', rgb(0,255,0),

if(Month = '1' and TDC_Element = 'Sales' and Balance <= BudgetAmount and Period = '1', rgb(0,192,0)

if(Month = '1' and TDC_Element <> 'Sales' and Balance > BudgetAmount and Period = '1', rgb(192,0,0)))

if(Month = '1' and TDC_Element <> 'Sales' and Balance <= BudgetAmount and Period = '1', rgb(255,0,0)))


if(Month = '1' and TDC_Element = 'Sales' and Balance > BudgetAmount and Period = '1', rgb(0,255,0),

if(Month = '1' and TDC_Element = 'Sales' and Balance <= BudgetAmount and Period = '1', rgb(0,192,0),

if(Month = '1' and TDC_Element <> 'Sales' and Balance > BudgetAmount and Period = '1', rgb(10,192,0),

if(Month = '1' and TDC_Element <> 'Sales' and Balance <= BudgetAmount and Period = '1', rgb(255,0,0)))))

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

Or

if(Month = '1' and Period = '1',

     if(TDC_Element = 'Sales',

          if(Balance > BudgetAmount, rgb(255,0,0), rgb(0,192,0))),

     if(TDC_Element <> 'Sales',

          if(Balance > BudgetAmount, rgb(0,192,0), rgb(255,0,0)))

)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
khanashique
Creator II
Creator II
Author

Hi Thiago,

Please find below table, Actuals are Balance column for each month same with Budget with each month:

       

TDC_ElementBudgetActualBudgetActualBudgetActual
Sales-109,147-6,947-110,893-18,862-112,507-17,800
Materials Cost32,0905,36132,16511,63131,31010,528
Operating Expenses9,36912,4269,5608,1859,75115,260
Utilities Expenses1,391-2,8951,4192,4481,4473,788
Outbound freight4,6539,6954,7484,4444,8436,040
Other Expenses2,1521,3012,1961,0962,2401,808

Thanks,

MAK.

khanashique
Creator II
Creator II
Author

Hi Jonathan,

Below expression provided by you, seems working but gives result for one condition only


if(Month = '1' and Period = '1',

     if(TDC_Element = 'Sales',

          if(Balance > BudgetAmount, rgb(255,0,0), rgb(0,192,0))),

     if(TDC_Element <> 'Sales',

          if(Balance > BudgetAmount, rgb(0,192,0), rgb(255,0,0)))

)


Thanks,

MAK.

khanashique
Creator II
Creator II
Author

Hi Jonathan,

Below expression does not return any result...

if(Month = '1' and TDC_Element = 'Sales' and Balance > BudgetAmount and Period = '1', rgb(0,255,0),

if(Month = '1' and TDC_Element = 'Sales' and Balance <= BudgetAmount and Period = '1', rgb(0,192,0),

if(Month = '1' and TDC_Element <> 'Sales' and Balance > BudgetAmount and Period = '1', rgb(10,192,0),

if(Month = '1' and TDC_Element <> 'Sales' and Balance <= BudgetAmount and Period = '1', rgb(255,0,0)))))

Thanks,

MAK.

khanashique
Creator II
Creator II
Author

Hi Jonathan,

Please see the snapshot below, Sales have not been applied any colour expression:

tab.JPG

Thanks,

MAK.

khanashique
Creator II
Creator II
Author

Hi Thiago / Jonathan,

A mistake i was doing, i did not do the summing of the balance and budget, after applying the following expression including sum expression, i got 'Sales' green but the other element is not red

if(TDC_Element = 'Sales' and Sum({<Year = {'2018'}, Month = {'1'}>}Balance) > Sum({<Year = {'2018'}, Period = {'1'}>}BudgetAmount) , 'Green',

if(TDC_Element <> 'Sales' and Sum({<Year = {'2018'}, Month = {'1'}>}Balance) > Sum({<Year = {'2018'}, Period = {'1'}>}BudgetAmount) , 'Red'))

when i apply following expression if i got other elements green but sales is not red


if(Year = '2018' and Month = '2' and Period = '2',

     if(TDC_Element = 'Sales',

          if(Sum(Balance) > Sum(BudgetAmount), rgb(255,0,0), rgb(0,192,0))),

      if(TDC_Element <> 'Sales',

           if(Sum(Balance) > Sum(BudgetAmount),  rgb(255,0,0), rgb(0,192,0)))

Just have a look on the above mentioned expressions.

Thanks and regards,

Ashik.

khanashique
Creator II
Creator II
Author

Hi All,

Please see the below expression, this worked perfectly fine as needed...Thanks a lot...

if(TDC_Element = 'Sales' and Sum({<Year = {'2018'}, Month = {'5'}>}Balance) > Sum({<Year = {'2018'},

Period = {'5'}>}BudgetAmount) , 'Green',

if(TDC_Element = 'Sales' and Sum({<Year = {'2018'}, Month = {'5'}>}Balance) < Sum({<Year = {'2018'},

Period = {'5'}>}BudgetAmount) , 'Red',

if(TDC_Element <> 'Sales' and Sum({<Year = {'2018'}, Month = {'5'}>}Balance) > Sum({<Year = {'2018'},

Period = {'5'}>}BudgetAmount) , 'Red',

if(TDC_Element <> 'Sales' and Sum({<Year = {'2018'}, Month = {'5'}>}Balance) < Sum({<Year = {'2018'},

Period = {'5'}>}BudgetAmount) , 'Green'))))

Regards,

MAK.