Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    corey1959 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    9

    Sum of NZ column

    New here...and fairly new to Access...but having an issue trying to sum a column. I've done an extensive Google search on this and I can't figure it out.

    I have a report that has a column called Net Profit. The formula I'm using is this:

    =Nz([NetSales],0)-Nz([GrandTotal],0)

    That works great to get the horizontal total of taking the NetSales and subtracting the Grand Total.

    Let's say...for simplicity sakes....that I have the following numbers:


    NET SALES GRAND TOTAL NET PROFIT
    $1000 $500 $500
    $400 $200 $200
    $700 $400 $300
    $300 $100 $200

    HOW can I total the Net Profit line so that it shows $1200 for the vertical column?

    Or is it even possible???

    Thanks

    Mike

    Edit: The columns won't line up after submitting....pretty much my day today....

  2. #2
    corey1959 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    9
    And I've tried this:

    =Sum(Nz([NetSales],0)-Nz([GrandTotal],0))

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    That expression should work. Is it in report footer section?

    To get aligned 'columns' in the post, use the table builder in Advanced post editor.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    What did that formula give as result? Not sure why it isn't working.

    You could try (guess only)

    =Sum(Nz([NetSales],0)) - Sum(Nz([GrandTotal],0))


    OOoops: I see June has responded while I was typing.

  5. #5
    corey1959 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    9
    Yes...it is in the report footer and I've tried it in the page footer.

    When I run either this:

    =Sum(Nz([NetSales],0)-Nz([GrandTotal],0))

    or this:

    =Sum(Nz([NetSales],0)) - Sum(Nz([GrandTotal],0))

    When I switch over to view the report, two dialog boxes pop up looking for a value for NetSales and GrandTotal. I have these named that in the Name properties of both sources. The names should....in theory....be OK since the code is working horizontally...

    Thanks for the replies. I am sure something simple is wrong.

    Mike

    edit: Once I click past the dialog boxes that pop up looking for a value for Net Sales and GrandTotal, the value returns as $0.00.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Are those the actual field names? Aggregate functions must reference fields, not controls.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    corey1959 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    9
    When I click on either field and bring up the properties box, under the "Name" box are those names. Not sure if this makes any difference, but the field called GrandTotal is generated using this:

    =Nz([SaleLotCost],0)+Nz([ExpenseCost],0)

    Again, those fields are named SaleLotCost and ExpenseCost in the properties Name box.

    Mike

  8. #8
    corey1959 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    9
    BTW...I agree with you all that the =Sum(Nz([NetSales],0)-Nz([GrandTotal],0)) "should" work....

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Then GrandTotal is not a field, it is just an unbound textbox with an expression. Options:

    1. do the simple arithmetic in the form's RecordSource query so there will be fields that can be referenced by the Sum() function

    2. do calc in textbox that uses the raw data fields

    =Sum(Nz([NetSales],0) - Nz([SaleLotCost],0) + Nz([ExpenseCost],0))

    Now is NetSales actually a field or just another unbound textbox with an expression?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    corey1959 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    9
    Ahhhh....

    NetSales is an unbound text box with an expression. Specifically:

    =Sum([PayPalPayment]-[Shipping]-[EbayListingFee]-[EbaySellingFee]-[PayPalFee])

    So...with that....does that change anything else?

    Mike

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Previous comments still apply. Adjust query and/or textbox expressions as needed.

    Might find this of interest http://allenbrowne.com/QueryPerfIssue.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    corey1959 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    9
    But do I need to change that NetSales field to reference my line of code that I posed above?

    When I run your code, it is returning a value, but it is still bringing up a dialog box looking for a value for NetSales. I'm guessing I need to reference this: =Sum([PayPalPayment]-[Shipping]-[EbayListingFee]-[EbaySellingFee]-[PayPalFee]) in your code.

    Mike

  13. #13
    corey1959 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    9
    I think I got it I'm going to have to check the numbers tomorrow but it looks right.

    I entered this:

    =Sum(Nz([PayPalPayment]-[Shipping]-[EbayListingFee]-[EbaySellingFee]-[PayPalFee],0)-Nz([SaleLotCost],0)+Nz([ExpenseCost],0))

    Mike

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Yep, as I said, adjust where needed.

    Aggregate functions must refer to fields, not controls.

    Remember, arithmetic with Null returns null. If any field of the NetSales calc is Null the return will be Null. Don't you want a number if any of the fields have a value? Or if one has data all 5 will?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    PMFJI,

    Is the record source for the report a table or query?

    I would do the calculation(s) in a query as June suggested (post #9 - point #1).
    Then it is a matter of summing controls in the footer for the 3 (virtual - aka calculated) fields.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 14
    Last Post: 07-13-2015, 12:47 PM
  2. Replies: 3
    Last Post: 03-02-2015, 09:50 AM
  3. Replies: 12
    Last Post: 10-08-2014, 02:35 PM
  4. Replies: 8
    Last Post: 07-29-2014, 12:35 PM
  5. Replies: 1
    Last Post: 04-15-2010, 02:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums