6 Replies Latest reply: Mar 23, 2016 10:52 AM by Stefan Wühl RSS

    Multiple IF and Sum syntax - Color Background Help

    patrico mesri

      Hi Community.

      Can anyone help me understand why my code does not work?

       

      I have a table like this in Qlik Sense.

       

      NamesCategory%
      PatrickB45
      MathewA80
      LeoJunior95

       

      I need to make a color background in the % column.

      When Category A is over 75%, paint it in green, red.

      When Category B is over 75%, paint it in green,  red.

      When Category Junio is over 95%. green, if not, red.

       

      The % column has the following sum:

       

       

      Sum({<"Facturable Real"={Facturable}>} Cantidad) / sum(Cantidad)

       

      So I tried the following syntax:

       

      if(Sum({<"Facturable Real"={Facturable},"Category"={"A"}>} Cantidad)

      /Sum({<"Category"={"A"}>} Cantidad)>=0.75,

      RGB(50,149,50), RGB(170,57,57) )

       

      So far this one works, but when I try to add more "IF" it gives me a syntax error... I tried using "and" and "or".

       

      .:::::::  If i Manage to connect the following it should work... .:::::...:


      if(Sum({<"Facturable Real"={Facturable},"Category"={"A"}>} Cantidad)

      /Sum({<"Category"={"A"}>} Cantidad)>=0.75,

      RGB(50,149,50), RGB(170,57,57) )


      if(Sum({<"Facturable Real"={Facturable},"Category"={"B"}>} Cantidad)

      /Sum({<"Category"={"B"}>} Cantidad)>=0.75,

      RGB(50,149,50), RGB(170,57,57) )

       

      if(Sum({<"Facturable Real"={Facturable},"Category"={"Junior"}>} Cantidad)

      /Sum({<"Category"={"Junior"}>} Cantidad)>=0.95,

      RGB(50,149,50), RGB(170,57,57) )

       

       

      Thank you in advance.

      Regards.