Alpha Video Training
Results 1 to 14 of 14

Thread: Expression Builder quirky behaviour for Numeric Fields.

  1. #1
    Member
    Real Name
    ken doucet
    Join Date
    Oct 2005
    Location
    Hamilton, Ontario
    Posts
    195

    Default Expression Builder quirky behaviour for Numeric Fields.

    I am running into a scenario where the calculated field expression / builder window is not giving me the resolution results for numeric fields. However, they are resolving correctly in the layout view. I have tried closing / reopening database and issue still persists. They were displaying OK earlier this evening. Now, when I want to edit N fields I can't see impact of any changes.

    Any ideas?

  2. #2
    Member
    Real Name
    ken doucet
    Join Date
    Oct 2005
    Location
    Hamilton, Ontario
    Posts
    195

    Default here is screen shot

    Attachment 11030

    Sorry, should have included this as well.

  3. #3
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default

    Ken,

    The LOOKUPN() passes an expression to be evaluated, but does not evaluate an expression in the parameter of a lookup as anything but a string to be passed to the function. Your code would have to be something more like

    F5/100*(VAL(F5/100*(VAL(ALLTRIM(RATEPERIOD))+LOOKUPN("F","LIFEi,"premium","rate.dbf","Irate"))
    LOOKUPN("F",ALLTRIM(RATEPERIOD)+"LIFEi,"premium","rate.dbf","Irate")

    If RatePeriod is a number and a field within rate.dbf, then it probably needs to be something like

    F5/100*LOOKUPN("F","RATEPERIOD+LIFEi,"premium","rate.dbf","Irate")

    But it's not clear what you want to return and evaluate. Let's say RATEPERIOD was equal to " 123 "
    In your version, the term

    LOOKUPN("F",ALLTRIM(RATEPERIOD)+"LIFEi,"premium","rate.dbf","Irate")

    would then be the same as

    LOOKUPN("F","123"+"LIFEi,"premium","rate.dbf","Irate")

    or more simply

    LOOKUPN("F","123LIFEi,"premium","rate.dbf","Irate")

    What does the return expression evaluate to in the rate table's record? It's garbage, and hence your problem.
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture



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

    Default

    Ken, does your problem go away when you reopen the database after shutting Alpha Five down?

    -- tom

  5. #5
    Member
    Real Name
    ken doucet
    Join Date
    Oct 2005
    Location
    Hamilton, Ontario
    Posts
    195

    Default

    Quote Originally Posted by Tom Cone Jr
    Ken, does your problem go away when you reopen the database after shutting Alpha Five down?

    -- tom
    I tried that and it didn't. I am suspecting the lookup(N) is the area to focus on since my other N expressions display this correctly
    RESULT: ....
    TYPE: N

    I know it was working since that was how I determined the correct coding by looking at RESULT data
    Last edited by ken doucet; 03-18-2006 at 08:25 AM.

  6. #6
    Member
    Real Name
    ken doucet
    Join Date
    Oct 2005
    Location
    Hamilton, Ontario
    Posts
    195

    Default

    Quote Originally Posted by csda1
    Ken,

    The LOOKUPN() passes an expression to be evaluated, but does not evaluate an expression in the parameter of a lookup as anything but a string to be passed to the function. Your code would have to be something more like

    F5/100*(VAL(F5/100*(VAL(ALLTRIM(RATEPERIOD))+LOOKUPN("F","LIFEi,"premium","rate.dbf","Irate"))
    LOOKUPN("F",ALLTRIM(RATEPERIOD)+"LIFEi,"premium","rate.dbf","Irate")

    If RatePeriod is a number and a field within rate.dbf, then it probably needs to be something like

    F5/100*LOOKUPN("F","RATEPERIOD+LIFEi,"premium","rate.dbf","Irate")

    But it's not clear what you want to return and evaluate. Let's say RATEPERIOD was equal to " 123 "
    In your version, the term

    LOOKUPN("F",ALLTRIM(RATEPERIOD)+"LIFEi,"premium","rate.dbf","Irate")

    would then be the same as

    LOOKUPN("F","123"+"LIFEi,"premium","rate.dbf","Irate")

    or more simply

    LOOKUPN("F","123LIFEi,"premium","rate.dbf","Irate")

    What does the return expression evaluate to in the rate table's record? It's garbage, and hence your problem.
    The rateperiod is text and LifeI as well. The two of them combined give me the key value in the index IRATE i.e. newlifei would be a record in rate table that returns a number like 1.394 and I use in multiplication with F5(N)/100 to generate N result.

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

    Default

    ken, are you trying to do

    (F5 / 1000) * lookupn()
    or

    F5 / (1000 * lookupn() )
    ???

    What is F5, and what is it's value when the expression editor tries to evaluate the expression? If table field, check the value. If variable, is it populated? is it in scope?

    -- tom

  8. #8
    Member
    Real Name
    ken doucet
    Join Date
    Oct 2005
    Location
    Hamilton, Ontario
    Posts
    195

    Default

    Quote Originally Posted by Tom Cone Jr
    ken, are you trying to do



    or



    ???

    What is F5, and what is it's value when the expression editor tries to evaluate the expression? If table field, check the value. If variable, is it populated? is it in scope?

    -- tom
    F5 (N) that itself is set to be 60000 if F4(L) is .T.
    then the (F5/1000)*lookupN........ is a formula that yields #of 1000 life insurance units which multiplied by the Lookup(N) formula (the premium per thousand). i.e. if F5 is 60000 then premium would be (60000/1000)*0.347 to yield the premium for that coverage.

    I am going out for 3 hours and will check thread as soon as I get back.

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

    Default

    Ken, let me try again.

    When you type F5 in the expression builder does it get properly evaluated?

    Do you get the same results when you include the parentheses to separate F5/1000 from the lookupn() ?

    -- tom

  10. #10
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default

    Ken,

    Quote Originally Posted by ken doucet
    The rateperiod is text and LifeI as well. The two of them combined give me the key value in the index IRATE i.e. newlifei would be a record in rate table that returns a number like 1.394 and I use in multiplication with F5(N)/100 to generate N result.
    Excuse a bit of my discussion, I had the key and return expression's backwards because I was typing at a machine that didn't have A5.

    Nevertheless, I'll ask these questions to you.
    1. Is rate.dbf in the same directory as the database (ADB file)? If not, provide a path to it.
    2. What is the expression for Irate index, and the definition of it's fields that make it up?
    3. So, for example, you are saying ALLTRIM(RatePeriod) evaluates to "new"? Add that to "LIFEi" results in a key of "newLIFEi".

    Try just the lookup field in the expression, without the F5/1000. See if that works. Try a fixed key like "newLIFEi" (if that is correct) instead of a calculation.

    Let us know how you make out.
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture



  11. #11
    Member
    Real Name
    ken doucet
    Join Date
    Oct 2005
    Location
    Hamilton, Ontario
    Posts
    195

    Default

    Quote Originally Posted by csda1
    Ken,



    Excuse a bit of my discussion, I had the key and return expression's backwards because I was typing at a machine that didn't have A5.

    Nevertheless, I'll ask these questions to you.
    1. Is rate.dbf in the same directory as the database (ADB file)? If not, provide a path to it.
    2. What is the expression for Irate index, and the definition of it's fields that make it up?

    3. So, for example, you are saying ALLTRIM(RatePeriod) evaluates to "new"? Add that to "LIFEi" results in a key of "newLIFEi".

    Try just the lookup field in the expression, without the F5/1000. See if that works.
    Try a fixed key like "newLIFEi" (if that is correct) instead of a calculation.

    The
    Let us know how you make out.
    1- yes
    2- character fields made up of PERIOD(C) and TYPE(C)
    3- Correct

    If I key this (F5/1000) the value resolves correctly (expected value returned). However,the Lookup field does not show RESULT TYPE yet the results are correctly computed and displayed in the layout view i.e. I change F4 value from .T. to .F. and data cycles to 0 (as it should) and then if I switch it back to .T. the correct N results display.

    In light of this should I try adding another field to my RATE table that is a join of the two fields?

  12. #12
    "Certified" Alphaholic
    Real Name
    Cal Locklin
    Join Date
    Mar 2000
    Location
    S.E. Michigan
    Posts
    5,763

    Default

    Are you sure the index in the lookup table trims the rate period? If not, determine the length of the Rateperiod field and make sure it is the same length in the lookup expression. If it is 10 characters, something like this:

    padr(RATEPERIOD,10," ")+"LIFEi"


    Another general hint: I've occasionally had problems with lookups that only use the table name even when the table is in the current folder. Adding the full path always solved the problem so I now make all table references in lookups like this:
    A5.Get_path() + "\rate.dbf"

    The errors I got said the table couldn't be found so it's not the same thing you are seeing here. This is just a "JIC" warning.

  13. #13
    Member
    Real Name
    ken doucet
    Join Date
    Oct 2005
    Location
    Hamilton, Ontario
    Posts
    195

    Default

    Quote Originally Posted by CALocklin
    Are you sure the index in the lookup table trims the rate period? If not, determine the length of the Rateperiod field and make sure it is the same length in the lookup expression. If it is 10 characters, something like this:

    padr(RATEPERIOD,10," ")+"LIFEi"


    Another general hint: I've occasionally had problems with lookups that only use the table name even when the table is in the current folder. Adding the full path always solved the problem so I now make all table references in lookups like this:
    A5.Get_path() + "\rate.dbf"

    The errors I got said the table couldn't be found so it's not the same thing you are seeing here. This is just a "JIC" warning.
    Just tried the get_path ... no change.

    The field Rateperiod is (C) max length 5 char.

    Tried the padr... and this did not do anything either.

  14. #14
    Member
    Real Name
    ken doucet
    Join Date
    Oct 2005
    Location
    Hamilton, Ontario
    Posts
    195

    Default Another item that may factor into this?

    My original RATE table was modelled on my old DOS database and the link was a dummy field called TIE(C) defaulting to "a". All my records in the Health Master table had a default field called TIE(C) defaulting to "a". I revamped my single record RATE table which necessitated complicated lookups - based on advice in another thread I now have multiple records in RATE table and do a LookupN() to grab the relevant premium.

    Is it possible my set using the TIE linking field has created this issue? This is my first usage of LookupN() so am not sure if I have inadvertently created this problem at the set leve.

    If it weren't for this current issue, I would have effectively remodelled this one area of my DOS table in a far more compact and efficient way. The coding, once I got into it is much easier thanks to inlist() etc..

    I appreciate any help I can get with this.

Similar Threads

  1. expression builder
    By John Burke in forum Alpha Five Version 6
    Replies: 1
    Last Post: 08-06-2004, 07:57 AM
  2. IF THEN ELSE in expression builder
    By Luc Verlee in forum Alpha Five Version 5
    Replies: 5
    Last Post: 02-05-2004, 04:39 AM
  3. Expression Builder
    By Bob Whitaker in forum Alpha Five Version 5
    Replies: 2
    Last Post: 01-16-2004, 03:15 AM
  4. Using the expression builder
    By Jim Dompier in forum Alpha Five Version 4
    Replies: 6
    Last Post: 10-23-2001, 07:55 AM
  5. expression builder
    By eric bellingham in forum Alpha Five Version 4
    Replies: 1
    Last Post: 01-06-2001, 03:24 PM

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
  •