0

Calculate the percentage if this result is negative

There is a field, "RESULT", where the result of the past day is shown. I need to calculate the percentage if this result is negative

9 replies

null
    • Fred
    • 5 mths ago
    • Reported - view

    Try the sign() command.

    if sign(RESULTS) = -1 then [code] end

      • iliper LTD
      • iliper_LTD
      • 5 mths ago
      • Reported - view

       Thanks for your reply Fred

      The formula doesn't work, it doesn't count. In the end, I need to calculate 10 percent if the result is negative

      • Fred
      • 5 mths ago
      • Reported - view

      Can you post your code?

      • iliper LTD
      • iliper_LTD
      • 5 mths ago
      • Reported - view

       Hello

      -max(Customer) * 'Customer DISC %'

      • Fred
      • 5 mths ago
      • Reported - view

        The original post asks to check for negative. Does that part work?

      Now you are having problem figuring out the discount?

      What kind of field is Customer?

      • iliper LTD
      • iliper_LTD
      • 4 mths ago
      • Reported - view

       Hi

      I solved the problem this way

      if 'Customer RESULT' < 0 then
          'Customer RESULT' * 'Customer DISC %'
      end

      • Fred
      • 4 mths ago
      • Reported - view

        I like the more common sense approach.

    • John_Halls
    • 4 mths ago
    • Reported - view

    This formula will return 1 if x is negative, and 0 if x is positive. You can then multiply it by your discount to return the discount or zero

    abs((sign(x)-1)/2)
    

    Regards John

      • iliper LTD
      • iliper_LTD
      • 4 mths ago
      • Reported - view

       Thanks for your reply

      Yes you are absolutely right, when negative, the value in the field is 1, but multiplying by one does not change anything. For example, when the result is -175 in the field where your formula is, the result is 1

Content aside

  • 4 mths agoLast active
  • 9Replies
  • 66Views
  • 3 Following