7 Replies Latest reply: Oct 10, 2017 2:02 PM by Satish Kamath RSS

    Variable based on other variable value

    Satish Kamath

      Hi All

       

      Is there anyway to define variable based on another variable value?

       

      Let say vVar evaluated value could be 1, 2, 3

       

      Now if I want to use above evaluated value in below definition as I mentioned in bold letters

      Is this possible without creating another variable and incorporate in same variable vXYZ?

      Because with another variable my report takes tremendous time(never end)

       

       

      vXYZ=
      If(sum({$<ThExp={'New'}>} RangeMax(ThMin, ThLow, ThMed, ThHgh, ThClg)) = sum({$<ThExp={'New'}>} ThMin), 1,
      If(sum({$<ThExp={'New'}>} RangeMax(ThMin, ThLow, ThMed, ThHgh, ThClg)) = sum({$<ThExp={'New'}>} ThLow), 1,
        If(sum({$<ThExp={'New'}>} RangeMax(ThMin, ThLow, ThMed, ThHgh, ThClg)) = sum({$<ThExp={'New'}>} ThMed), 2,
         If(sum({$<ThExp={'New'}>} RangeMax(ThMin, ThLow, ThMed, ThHgh, ThClg)) = sum({$<ThExp={'New'}>} ThHgh), 3,
          If(sum({$<ThExp={'New'}>} RangeMax(ThMin, ThLow, ThMed, ThHgh, ThClg)) = sum({$<ThExp={'New'}>} ThClg), 3

       

      if (vVar = 1, vXYZ * 10,
      if (vVar = 2, vXYZ * 20,
        if (vVar = 1, vXYZ * 10)))
      )))))

       

      I appreciate your suggestion. Thanks a lot

        • Re: Variable based on other variable value
          Sunny Talwar

          Would it give better performance if you reduce the number of hops... may be... I am not sure and I have never done the testing... but why not consider using Pick(Match()) instead of nested if? May be it can help you here

          • Re: Variable based on other variable value
            pradosh thakur

            Hi

             

            please check if any brackets are missed or any syntax error is there. give it a  go and see if it works

            v_var=

            match(sum({$<ThExp={'New'}>} RangeMax(ThMin, ThLow, ThMed, ThHgh, ThClg)) ,sum({$<ThExp={'New'}>} ThMin),  sum({$<ThExp={'New'}>} ThLow),sum({$<ThExp={'New'}>} ThMed), sum({$<ThExp={'New'}>} ThHgh)sum({$<ThExp={'New'}>} ThClg))

             

             

            compared to your previous logic(which you can easily adjust)

            brown for 1 which will now return 1 and 2

            green for 2 which will now return 3 and 4

            blue for 3 which will now return 5

             

            pick($(=v_var),v_xyz*10,v*xyz*10,v_xyz*20,v*xyz*20,v_xyz*30)


            stalwar1 can correct me if i am wrong anywhere


            regards

            Pradosh