1 Reply Latest reply on Nov 21, 2018 7:12 PM by swaroop.gantela

    Help with Categorizing Data into Buckets!

    Amosh Neupane

      Hello All,

       

      I'm new to tableau and stuck at this problem for a bit: I am hopping to categorize data from one column into buckets by using four different conditions. There are four different benchmarks for each unique "rpt_metric" and I'm having a hard time executing this task. The error message I keep receiving is, "Expected END to Match IF at character 322." To give you an example:

       

      rpt_metric
      metric percentage
      Header 3
      AHT700
      CEI_Overall_Top_Box_7pt701
      Overall_Call_Quality702
      Safeguard704
      AHT705
      AHT706
      SAfeguard707

       

       

      IF MAX(([rpt_metric])) = "AHT" THEN

      IF [Metric Percentage] <= <insert benchmark here> THEN "GREEN"

      ELSEIF [Metric Percentage] <= <insert benchmark here> THEN "YELLOW"

      ELSE "RED"

      OR

      IF MAX(([rpt_metric])) = "CEI_Overall_Top_Box_7pt" THEN

      IF [Metric Percentage] >= <insert benchmark here> THEN "GREEN"

      ELSEIF [Metric Percentage] >= <insert benchmark here> THEN "YELLOW"

      ELSE "RED"

      OR

      IF MAX(([rpt_metric])) = "Overall_Call_Quality" THEN

      IF [Metric Percentage] >=<insert benchmark here> THEN "GREEN"

      ELSEIF [Metric Percentage] >= <insert benchmark here> THEN "YELLOW"

      ELSE "RED"

      END

      OR

      IF MAX(([rpt_metric])) = "Safeguard" THEN

      IF [Metric Percentage] >= <insert benchmark here> THEN "GREEN"

      ELSEIF [Metric Percentage] >= <insert benchmark here> THEN "YELLOW"

      ELSE "RED"

      END

      END

       

      I have seen a couple of forum responses about similar topics and I tried incorporating them into my sheet, but to be frank, I am rather lost. Any and all help will be appreciated.

        • 1. Re: Help with Categorizing Data into Buckets!
          swaroop.gantela

          Amosh,

           

          I think the structure was pretty much there.

          It was needed in more "END"s after the 1st and 2nd metric.

          Also, you may not need to use OR.

           

          Here is an example:

          IF ATTR([RPT_Metric])="Discount" THEN

              IF SUM([Metric Value])<=500 THEN "Green"

              ELSEIF SUM([Metric Value])<=1000 THEN "Yellow"

              ELSE "Red"

              END

          ELSEIF ATTR([RPT_Metric])="Profit" THEN

              IF SUM([Metric Value])<=100000 THEN "Green"

              ELSEIF SUM([Metric Value])<=150000 THEN "Yellow"

              ELSE "Red"

              END

          ELSEIF ATTR([RPT_Metric])="Quantity" THEN

              IF SUM([Metric Value])<=10000 THEN "Green"

              ELSEIF SUM([Metric Value])<=15000 THEN "Yellow"

              ELSE "Red"

              END

          END

           

          I think this could also be done with a CASE statement

          which might be cleaner.

           

          Please see workbook v10.3 attached in the Forum Thread:

          Help with Categorizing Data into Buckets!