3 Replies Latest reply: Jul 18, 2017 6:12 AM by Anil Babu Samineni RSS

    Help With Complex "If ElseIF ElseIF" Statement

    Aron Williamson

      Hi All,


      I need some help with this as its not as easy as I first thought it might be.

      The scenario is that our customers will receive a rebate on there spend as long as they spend more than there agreed threshold.


      An example of this: If customer 1001 spends more than £100,000 then they will receive 2% rebate of there spend, however if they spend more than £200,000 then they receive %3 rebate.


      What I Want to Achieve

      We want to be able to show automatically the percentage of rebate that each customer will receive for each invoice and then calculate the rebate amount for each invoice.



      We have a maximum of 4 tiers of rebate however not all customers have 4 tiers, some have 1 flat rate, some have 2 tiers some 3 and some all 4.


      The percentage and threshold is different for some  customers but not all e.g. customer 1001 has a different threshold and percentage rate to customer 1006


      What I Have In Mind

      To resolve the problems above I figured it would be best to map in an excel sheet (Test Attached) that contains columns of:

      The Customer Number (KEY), Threshold 1 , %Tier 1 , Threshold 2, %Tier 2, Threshold 3, %Tier 3 ,Threshold 4, %Tier 4

      I need help figuring out how to test the customer spend against each threshold however break if the next threshold is NULL.



      var = 0


      IF (customer spend < threshold 1)THEN(Break)

      ELSE (

      IF (customer spend > threshold 1 & < threshold 2) THEN (SET var=%Tier1)

      ELSEIF ( IF(%Tier2 = NULL) THEN (BREAK) ELSE (customer spend > threshold 2 & < threshold 3) THEN (SET var=%Tier2))

      ELSEIF ( IF(%Tier3 = NULL) THEN (BREAK) ELSE (customer spend > threshold 3 & < threshold 4) THEN (SET var=%Tier3))

      ELSE ( IF(%Tier4 = NULL) THEN (BREAK) ELSE (SET var=%Tier4))






      Message was edited by: Aron Williamson Changed psuedo Script