Access Sum Function Criteria

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rhonda6373
    New Member
    • Mar 2010
    • 35

    #1

    Access Sum Function Criteria

    Hello,

    I am trying to sum a column on a subform named Cost of New if another column named Final = any of the values listed in my code. However, it is summing the Cost of New column regardless of the values of Final. It is summing for all values.

    What do I need to modify to make this correct or should I do it another way?

    Code:
    =IIf([Final]="RPR-RPR & RTN" Or [Final]="NFF-TST & NFF" Or [Final]="RTN-RETURN" Or [Final]="SCL-SCR LOCALLY" Or [Final]="SCR-SCR RETURN" Or [Final]="BER-BER RTN CST",Sum([Cost Of New]),Null)
    Thanks!

    Rhonda
  • jforbes
    Recognized Expert Top Contributor
    • Aug 2014
    • 1107

    #2
    I'm not exactly sure what you are trying to do, but typically the Sum() goes on the outside of an expression:
    Code:
    =Sum(IIf([Final]="RPR-RPR & RTN" Or [Final]="NFF-TST & NFF" Or [Final]="RTN-RETURN" Or [Final]="SCL-SCR LOCALLY" Or [Final]="SCR-SCR RETURN" Or [Final]="BER-BER RTN CST",Nz([Cost Of New], 0),0))
    Also, Sum doesn't always work the way you expect with Nulls, so setting them to 0 is usually (not always) better.

    If this isn't what you are after, please let us know a little more of what you are trying to do.

    Comment

    • rhonda6373
      New Member
      • Mar 2010
      • 35

      #3
      That is what I am looking for, thank you!

      Comment

      Working...