Forum Discussion

Ykankam's avatar
Ykankam
Helper I
2 years ago
Solved

switch not working correctly

I am using SWITCH function to get 4 different values. The first 3 works as expect, but the last condition does not return the expected value which is "Terminated". What could I be doing wrong?  Values from the highlighted column should be "Terminated".

  • Ykankam ,

    The SWITCH function works in sequence.  If it doesn't find Condition 1, it moves to the next.

    My assumption here, without seeing all of the columns in your dataset, is that all of the conditions for "In Progress" are being met, so the SWITCH never reaches Condition 4 for "Terminated".

    Try moving the "Terminated" Condition to be the 1st or 2nd and see if that resolves your issue.

    Regards,

3 Replies

  • rsbin's avatar
    rsbin
    Community Champion

    Ykankam ,

    The SWITCH function works in sequence.  If it doesn't find Condition 1, it moves to the next.

    My assumption here, without seeing all of the columns in your dataset, is that all of the conditions for "In Progress" are being met, so the SWITCH never reaches Condition 4 for "Terminated".

    Try moving the "Terminated" Condition to be the 1st or 2nd and see if that resolves your issue.

    Regards,

    • Ykankam's avatar
      Ykankam
      Helper I

      tackytechtom thanks for your input. Since SWICTH works in a sequencial order, i had to place the terminated condition first. Code now looks like as shown below

      GoldenBatch =
      SWITCH (
          TRUE (),
          [termstatus] = "Term", "Terminated",
          [thaw_onTime] = "Y"
              && [proA_onTime] = "Y"
              && [BDS_onTime] = "Y"
              && [harvest_onTime] = "Y"
              && [%RFT_RFT] = "Y"
              && [titer_inFull] = "Y"
              && [yield_inFull] = "Y"
              && [deviation_RFT] = "Y", "Golden Batch",
          [thaw_onTime] = "N"
              || [proA_onTime] = "N"
              || [BDS_onTime] = "N"
              || [harvest_onTime] = "N"
              || [%RFT_RFT] = "N"
              || [titer_inFull] = "N"
              || [yield_inFull] = "N"
              || [deviation_RFT] = "N", "Miss",
          [thaw_onTime] = BLANK ()
              || [proA_onTime] = BLANK ()
              || [BDS_onTime] = BLANK ()
              || [harvest_onTime] = BLANK ()
              || [%RFT_RFT] = BLANK ()
              || [titer_inFull] = BLANK ()
              || [yield_inFull] = BLANK ()
              || [deviation_RFT] = BLANK (), "In Progress"
      )