3 Replies Latest reply: May 14, 2018 5:38 PM by Ivan Bozov RSS

    Color expression in Charts, Do I need to nest 25 Ifs?

    Charles Demarest

      Hi,  I want to have the same of 24 industry groups to be displayed in the same color across charts.  I realized that this can be done if I just use the same color expression in the different charts.  However, for this purpose anyway, it seems Qliksense does not have a "case" or "switch" syntax and I need to compose 23 nested if statements.  Here is what I have and it works, so non-urgent but if someone knows of a better way please let me know:

       

      if([GICS Industry Group] = 'Automobiles & Components',red(),

      if([GICS Industry Group] = 'Banks',blue(),

      if([GICS Industry Group] = 'Capital Goods',black(),

      if([GICS Industry Group] = 'Commercial & Professional Services',DarkGray(),

      if([GICS Industry Group] = 'Consumer Durables & Apparel',LightBlue(),

      if([GICS Industry Group] = 'Consumer Services',rgb(255,218,185),

      if([GICS Industry Group] = 'Diversified Financials',green(),

      if([GICS Industry Group] = 'Energy',lightGreen(),

      if([GICS Industry Group] = 'Food & Staples Retailing',Cyan(),

      if([GICS Industry Group] = 'Food Beverage & Tobacco',rgb(255,165,0),

      if([GICS Industry Group] = 'Health Care Equipment & Services',rgb(192,192,192),

      if([GICS Industry Group] = 'Household & Personal Products',rgb(255,105,180),

      if([GICS Industry Group] = 'Insurance',rgb(192,192,192),

      if([GICS Industry Group] = 'Materials',LightGray(),

      if([GICS Industry Group] = 'Media',rgb(176,196,222),

      if([GICS Industry Group] = 'Pharmaceuticals Biotechnology & Life Sciences',rgb(0,0,0),

      if([GICS Industry Group] = 'Real Estate',rgb(255,20,147),

      if([GICS Industry Group] = 'Retailing',yellow(),

      if([GICS Industry Group] = 'Semiconductors & Semiconductor Equipment',rgb(255,0,255),

      if([GICS Industry Group] = 'Software & Services',rgb(186,85,211),

      if([GICS Industry Group] = 'Technology Hardware & Equipment',rgb(75,0,130),

      if([GICS Industry Group] = 'Telecommunication Services',magenta(),

      if([GICS Industry Group] = 'Transportation',lightRed(),

      rgb(255,0,255))))))))))))))))))))))))