2 Replies Latest reply on Sep 21, 2011 10:01 AM by carojvi

    Ratio format 5:1

    carojvi

      Hello,

      Is it possible to have a formula that would result in something looking like 5:1 instead of 20%?

      I have 2 numeric fields, and I want the 3rd to show the ratio between the 2.

      Thank you,

      Caroline

        • 1. Re: Ratio format 5:1
          radzmar Adobe Community Professional & MVP

          Hi,

           

          this is only a formula from scratch, but it seems to work.

          Put it into the calculate event of the 3rd field (must be a text field!!!).

          Attention: This is ForcCalc not JavaScript, so make sure to select the correct language in the script editor.

          var a = NumberField1

          var b = NumberField2

          var max = Max(a, b)

          var min = Min(a, b)

           

           

          if (max gt 0 and min gt 0) then

                    var ratio

                    var perc = Round((100 / max) * min, 1)

                    var hundred = 100

           

                    for i = 1 upto Round(100/perc, 1) step 1 do

                                        hundred = hundred - perc

                                        ratio = i

                    endfor

           

                    $ = Concat(ratio, ":", 1)

          endif

          • 2. Re: Ratio format 5:1
            carojvi Level 1

            Hi,

            Thank you, it does seem to work! Genius