Skip to main content
Question

My code using Sum function with the - operator.

  • Sep 24, 2018 5:20 PM UTC
  • 8 replies
  • 128 views

 What is wrong with my code?   [Apply Discount] is a checkbox  the rest are numeric formula fields.  [Discount] is a numeric field.  It will Sum but fails to subtract the [Discount] even when not used in the IF statement. 

If([Apply Discount]= true, Sum ([SoftScape Total],[HardScape Total],[Aggregate Total],[Removal Total]-[Discount]),Sum([SoftScape Total],[HardScape Total],[Aggregate Total],[Removal Total]))
This topic has been closed for replies.

8 replies

Forum|alt.badge.img+17
  • Quickbase Staff
  • Sep 24, 2018 5:24 PM UTC
Hi Billy,

Have you tried wrapping just the section with the subtraction in its own set of parenthesis?

If([Apply Discount]= true, Sum ([SoftScape Total],[HardScape Total],[Aggregate Total],([Removal Total]-[Discount])),Sum([SoftScape Total],[HardScape Total],[Aggregate Total],[Removal Total]))

Just to make sure that Subtraction is being calculated first.

  • Author
  • Qrew Cadet
  • Sep 24, 2018 5:27 PM UTC
Let me give it a shot. 


  • Author
  • Qrew Cadet
  • Sep 24, 2018 5:29 PM UTC
It still doesn't do the subtraction.  I get the sum total whether Apply discount is checked or not. 

Billy,
Is the discount a dollar amount number or a %?

Forum|alt.badge.img+17
  • Quickbase Staff
  • Sep 24, 2018 5:32 PM UTC
Could you try putting in 1 instead of true for your checkbox really quick and see what you get back?

So [Apply Discount]=1

  • Author
  • Qrew Cadet
  • Sep 24, 2018 5:32 PM UTC
Good idea though, Here is the code that worked.    What you said made me think.  

If([Apply Discount]= true, Sum ([SoftScape Total],[HardScape Total],[Aggregate Total],[Removal Total])-([Discount]),Sum([SoftScape Total],[HardScape Total],[Aggregate Total],[Removal Total]))

  • Author
  • Qrew Cadet
  • Sep 24, 2018 5:32 PM UTC
It is a dollar amount. 

  • Author
  • Qrew Cadet
  • Sep 24, 2018 5:33 PM UTC
The code I posted above worked.  Just the subtraction part needed to be in its own set of parentheses.