Get a Jumpstart with our Sample Apps
Results 1 to 3 of 3

Thread: Total Function

  1. #1
    Member
    Real Name
    Richard Webb
    Join Date
    Nov 2008
    Posts
    7

    Default Total Function

    I have a database called collection_2016 with a field AMT, and a field NO
    I am trying to have a calculated field Calc_Sum put a subtotal next to each record
    so if there is 5 records with NO=7 and each AMT=10 then CalcSum would = 50 for each NO=7 record
    8 records NO=14 and each AMT=3 then CalcSum would be 24 for each NO=14 record
    How do I subtotal within a calculated field, not a report?

  2. #2
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,211

    Default Re: Total Function

    Hi Richard,

    Try this for the calc field and drag it onto the browse:

    testsum = tablesum("test","no = "+test->no,"amt")

    testsum.jpg
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  3. #3
    Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,383

    Default Re: Total Function

    Another option is:

    Make an index for No in the table "test" and use dbsum.

    mytotaldbsum = dbsum("test","No",No,"Amt")

    Regardless of the choice you make, if there is enough data, you should make an index for performance.

    TABLE()and DB() functions Contrasted

    Although the corresponding TABLE()and DB() functions are similar, there are differences between the two. The TABLE() functions have a simpler syntax, and are more powerful because they take a full filter expression. However, the TABLE() functions tend to be slower unless they can take advantage of Lightning Query Optimization. The DB() functions are more complex to write and are less flexible, but execute quicker.

    See Also

    Record Functions, TABLEAVG(), TABLECOUNT(), TABLEMAX(), TABLEMIN(), TABLESUM(), DBAVG(), DBCOUNT(), DBMAX(), DBMIN(), DBSUM()
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

Similar Threads

  1. Total() function in a form???
    By Gustavo1478 in forum Windows Desktop Applications
    Replies: 24
    Last Post: 03-28-2014, 09:56 AM
  2. Running total function
    By Dr Alok Modi MD in forum Alpha Five Version 5
    Replies: 7
    Last Post: 05-01-2004, 01:04 PM
  3. Total () Function
    By Martin Konieczny in forum Alpha Five Version 5
    Replies: 3
    Last Post: 07-28-2003, 08:06 AM
  4. odd total function required
    By eeetee in forum Alpha Five Version 4
    Replies: 4
    Last Post: 11-21-2002, 08:03 AM
  5. TOTAL function
    By David Patterson in forum Alpha Five Version 4
    Replies: 2
    Last Post: 06-20-2001, 09:09 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
  •