4 Replies Latest reply on Jul 24, 2018 10:32 AM by jon rios

    If Statement structure

    jon rios

      here is an IF Statement, it currently erroring " END is needed", but when i make changes, it continues to error with different messages, is there a better way to structure this?  would a CASE avoid these errors?  thanks for any assistance

       

        • 1. Re: If Statement structure
          Naveen B

          Hi Jon

           

          you are using aggregation every if statement overall you can do like below but  i doubt you need another way showing this information because first if statement validate all the data so 3rd if statement wont get executed . Could you please attach sample excel and how you want the output so that it will be easy to help

           

          SUM

          (If [segment value active]="Open" or

          [segment_label12]="12 to <24"

          or [segment_label12]="24 to <36" then

          three_segpromotenewsum/three_segaccount_count

          elseif

          [segment value active]="Open" or

          [segment_label12]="36 to<60"

          or [segment_label12]="60+" then

          three_segpromotenewsum/three_segaccount_count

          elseif segment_value_active = "Open"

          then

          three_segpromotenewsum/three_segaccount_count

          else

          0

          )

           

          BR,

          NB

          1 of 1 people found this helpful
          • 2. Re: If Statement structure
            Deepak Rai

            Why You Need to Put SUM  Before Each If?

            1 of 1 people found this helpful
            • 3. Re: If Statement structure
              meenu choudhary

              Hi Jon,

               

              your attachment doesn't give the entire calculation. But what i can suggest by looking into whatever is there is :

               

              sum(if [segment value active]="open" and ([segmentLabel12]="12 to <24" OR [segmentLabel12]="36 to <60  ....and all the filters for segmentLabel12") then [ThreeSeg_PromoNetAmountSum] else 0 end) 

              /

               

              [ThreeSeg_PromoNetAmountCount]

              • 4. Re: If Statement structure
                jon rios

                hi Meenu, all the calculations are there, 3 separate IF statements...

                 

                but it doesnt matter, your solution was the key... separate the denominator.... that gives me the correct answer! thanks