Alpha Video Training
Results 1 to 5 of 5

Thread: need to filter and sum fileds in a set

  1. #1
    Member
    Real Name
    gary keramidas
    Join Date
    Jul 2000
    Location
    Michigan
    Posts
    420

    Default need to filter and sum fileds in a set

    i tried tablesum but it only seems to work on individual tables. what' s the easiest way to be able to filter records and then do some calcs, such as sum a certain column?

    should i use a query, and if so, how would i get the sum of a field in the set?

  2. #2
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,096

    Default Re: need to filter and sum fileds in a set

    gary,

    i have in my app been able to cacualte the sum of a field in an embeded browse which is based upon a set. (if this is what you need).

    here is an example which will filter the total based upon certain criteria
    Code:
    tablesum("debts","caseref ="+quote(caseref.value)+" .and. commrepaid=.T.","commmonthly")
    just place a new calculated field on your form and place the code in the form which opens.

    my parent table is 'Caseref'
    my child table is 'Debts'

    the expression filters the table debts based upon the linking field between the parent and child table which in this case is 'caseref'.

    i needed to filter the total where a clients debt would be repaid from all of the debts entered for that client. so the filter is 'coomrepaid=.T.' and the field to be totaled is 'commmonthly'.

    if oyu just want a simple total of all records for that client, just drag a new field from the field list (dragdrop List) and place on your form (its best if you have the genie switched on on the dragdrop list) when you release your mouse the genie will pop up and ask you what you want to do. just select TOTAL OF THE FIELDS.

  3. #3
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default Re: need to filter and sum fileds in a set

    Gary, sets don't have fields. Sets have tables. Tablesum(), Dbsum(), and Total() are all designed to sum fields in a table. What do you mean when you want to sum a field in a set?

  4. #4
    Member
    Real Name
    gary keramidas
    Join Date
    Jul 2000
    Location
    Michigan
    Posts
    420

    Default Re: need to filter and sum fileds in a set

    tom:

    in some of alpha's help files, Lookup_Table can be a set name. i was trying to use tablesum in that context.

    tablesum(setname.set, "lines->model = test", "data->weight") to get the sum of weight in the set.
    i endup trying this in code and it seems to work:
    query.filter = "lines->model = test"
    i = tbl.query_create()
    tbl.field_statistics("weight",answer)

  5. #5
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,937

    Default Re: need to filter and sum fileds in a set

    Gary,
    in some of alpha's help files, Lookup_Table can be a set name
    I did a fairly thorough search and could only find this so far which would somewhat confirm what you are saying...that when using a combo box dropdown on a form field, it does offer you to use a table or set--even lists the set and you can choose it---but when a set is chosen it doesn't work (for me at least!) in that no data will show up whereas when the same fields are chosen from their corresponding table, the values do show up.

    So I can see where it could be a bit confusing...if this was where you were referring to. If not give a link.
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________




Similar Threads

  1. How to delete calculated fileds in the dragdrop list
    By georgefurnel in forum Alpha Five Version 8
    Replies: 2
    Last Post: 04-18-2008, 11:58 AM
  2. how many calc fileds or error?
    By DaveM in forum Alpha Five Version 7
    Replies: 23
    Last Post: 03-01-2007, 06:19 PM
  3. Subtract fileds with filter
    By samed in forum Alpha Five Version 7
    Replies: 0
    Last Post: 02-04-2007, 07:41 PM
  4. Calculated Fileds - limited number in table?
    By Truman in forum Alpha Five Version 6
    Replies: 2
    Last Post: 09-19-2005, 02:40 PM
  5. A5v4.5 character fileds
    By Thibaud Chabot in forum Alpha Five Version 4
    Replies: 5
    Last Post: 02-23-2001, 12:03 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •