Alpha Video Training
Results 1 to 7 of 7

Thread: Quick Calculation Question

  1. #1
    Member
    Real Name
    Melvin
    Join Date
    Nov 2011
    Posts
    133

    Default Quick Calculation Question

    Hi All

    I'm having an issue with with a tablesum expression.

    The problem is with the filter. Both parts of the filter work on their own, but not when i add the .and..

    Can anyone advise me on what I'm doing wrong?

    Code:
    tablesum("data_order.dbf","cust_id =' " + data_order->cust_id + " '  .and. " Data_Order->pay_typ = ' " + "Open Account" + " ' "","Data_Order->Totdf_Cinv")

  2. #2
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,643

    Default Re: Quick Calculation Question

    I build a variable with the filter in it, then use the variable in the function.

    That way I can 'see' that is going on...

    Code:
    dim customfilter as C
    customfilter="cust_id =' " + data_order->cust_id + " '  .and. " Data_Order->pay_typ = ' " + "Open Account" + " ' ""
    msgbox(customfilter)' or use debug(1) - remove either when done 
    tablesum("data_order.dbf",customfilter,"Data_Order->Totdf_Cinv")
    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.

  3. #3
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Quick Calculation Question

    Looks like the filter should be

    "cust_id ='" + data_order->cust_id + "' .and. Data_Order->pay_typ = '" + "Open Account" + "' "

    to be on the safe side one should probably use

    "cust_id ='" + alltrim(data_order->cust_id) + "' .and. Data_Order->pay_typ = '" + "Open Account" + "' "
    Last edited by Stan Mathews; 12-13-2012 at 02:45 PM.

  4. #4
    Member
    Real Name
    Melvin
    Join Date
    Nov 2011
    Posts
    133

    Default Re: Quick Calculation Question

    That worked nicely...Still trying to get used to building expressions.

    Thanks for your help Stan!

  5. #5
    "Certified" Alphaholic Ray in Capetown's Avatar
    Real Name
    Ray Hendler
    Join Date
    Jan 2009
    Location
    South Africa
    Posts
    2,036

    Default Re: Quick Calculation Question

    Sorry. That will always be .F.
    I recon. its not including the value of pay_typ
    It's being complicated by also including a literal.
    Should probably be;-
    Code:
    "cust_id =' " + data_order->cust_id + " '  .and. '"+ data_order->pay_typ +"'='Open Account'"
    results in,
    assuming;-
    Code:
    cust_id="0987890000"
    pay_typ="CASH"
    Code:
    cust_id =" 0987890000 "  .and. "CASH"="Open Account"

  6. #6
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Quick Calculation Question

    Still trying to get used to building expressions
    Me too.

  7. #7
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,643

    Default Re: Quick Calculation Question

    Quote Originally Posted by Ray in Capetown View Post
    results in,
    assuming;-
    If you use the method I suggested, you won't be assuming....
    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. quick help with a calculation
    By hov333 in forum Alpha Five Version 10 - Desktop Applications
    Replies: 51
    Last Post: 08-24-2011, 01:35 PM
  2. Another Quick Question
    By Rick Canady in forum Alpha Five Version 5
    Replies: 9
    Last Post: 01-27-2004, 04:24 AM
  3. Quick Question
    By Rick Canady in forum Alpha Five Version 5
    Replies: 4
    Last Post: 01-24-2004, 09:53 AM
  4. quick question
    By dik_coleman in forum Alpha Five Version 5
    Replies: 14
    Last Post: 12-19-2003, 08:37 PM
  5. Quick - Quick Filter Question
    By forskare in forum Alpha Five Version 4
    Replies: 2
    Last Post: 05-08-2001, 10:08 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
  •