Alpha Video Training
Results 1 to 18 of 18

Thread: calculated field expression

  1. #1
    Member Kamel's Avatar
    Real Name
    Kamel Jazmati
    Join Date
    Nov 2010
    Location
    Jeddah, Saudi Arabia
    Posts
    97

    Question calculated field expression

    hi all,

    how I can put some thing like this in calculated field expression:

    if(M_filter = "Oil", M_filter_oil_price, 0)
    if(M_filter = "Air", M_filter_air_price, 0)
    if(M_filter = "Fuel", M_filter_fuel_price, 0)

    Please any help or suggestion !?

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

    Default Re: calculated field expression

    Quote Originally Posted by Kamel View Post
    hi all,

    how I can put some thing like this in calculated field expression:

    if(M_filter = "Oil", M_filter_oil_price, 0)
    if(M_filter = "Air", M_filter_air_price, 0)
    if(M_filter = "Fuel", M_filter_fuel_price, 0)

    Please any help or suggestion !?
    result = case(M_filter = "Oil", M_filter_oil_price,M_filter = "Air", M_filter_air_price,M_filter ="Fuel", M_filter_fuel_price..

    Apologies if this has already been answered, I called away for a couple of hours
    Ray
    Last edited by Ray in Capetown; 06-25-2011 at 08:45 AM. Reason: not done

  3. #3
    Member Kamel's Avatar
    Real Name
    Kamel Jazmati
    Join Date
    Nov 2010
    Location
    Jeddah, Saudi Arabia
    Posts
    97

    Default Re: calculated field expression

    thanks Ray,

    but it doesn't work with calculated field expression,
    case() doesn't listed in functions list,,,

  4. #4
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,355

    Default Re: calculated field expression

    Quote Originally Posted by Kamel View Post
    hi all,

    how I can put some thing like this in calculated field expression:

    if(M_filter = "Oil", M_filter_oil_price, 0)
    if(M_filter = "Air", M_filter_air_price, 0)
    if(M_filter = "Fuel", M_filter_fuel_price, 0)

    Please any help or suggestion !?
    I tried this assuming that M_filter_oil_price, M_filter_air_price, and M_filter_fuel_price are seperate fields for each record.
    I created a calculated field named Cprice in the Query(DBF) section, with the following code
    Code:
     case(M_Filter="Oil",M_Filter_Oil_Price,M_Filter="Air",M_Filter_Air_Price,M_Filter="Fuel",M_Filter_Fuel_Price)
    This accomplishes what you asked for, but does not seem to be what you really wanted.

  5. #5
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,643

    Default Re: calculated field expression

    Case is a valid function. But I guess it depends where you are defining it. If you are partial to IF, try this:

    if(M_filter = "Oil", M_filter_oil_price, if(M_filter = "Air", M_filter_air_price, if(M_filter = "Fuel", M_filter_fuel_price, 0)))

  6. #6
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,355

    Default Re: calculated field expression

    I tried using IF in the clientside calculations, but kept getting a circular reference error.

  7. #7
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,643

    Default Re: calculated field expression

    Quote Originally Posted by madtowng View Post
    I tried using IF in the clientside calculations, but kept getting a circular reference error.
    Where are you using this?

  8. #8
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,355

    Default Re: calculated field expression

    Hi Peter,

    The attached pic says it so much better than I can.

    I know I didin't get to the false part of the statement, but the error showed up before I got that far.

  9. #9
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,643

    Default Re: calculated field expression

    Yeah, client side expressions are basically JavaScript. Alpha gives us some basic "wrapper" functions, but they are very limited.

  10. #10
    Member Kamel's Avatar
    Real Name
    Kamel Jazmati
    Join Date
    Nov 2010
    Location
    Jeddah, Saudi Arabia
    Posts
    97

    Default Re: calculated field expression

    Quote Originally Posted by Peter.Greulich View Post
    Case is a valid function. But I guess it depends where you are defining it. If you are partial to IF, try this:

    if(M_filter = "Oil", M_filter_oil_price, if(M_filter = "Air", M_filter_air_price, if(M_filter = "Fuel", M_filter_fuel_price, 0)))
    Thanks Peter,
    that what i want, :)

  11. #11
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,355

    Default Re: calculated field expression

    Where are you planning to put that code (I'm a bit curious because of the trouble I had with it) ?

  12. #12
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,670

    Default Re: calculated field expression

    Quote Originally Posted by madtowng View Post
    Hi Peter,

    The attached pic says it so much better than I can.

    I know I didin't get to the false part of the statement, but the error showed up before I got that far.
    What's "a result_false" in the else part of the statement? It looks like that is what's causing the problem - it would be interpreted as 2 variables or field names. Peter's "if" statement works in the client-side properties, calculated field expression - you're allowed the nested if statements in there - it gets converted to the equivalent javascript nested if statement.

  13. #13
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,355

    Default Re: calculated field expression

    Quote Originally Posted by Davidk View Post
    What's "a result_false" in the else part of the statement? It looks like that is what's causing the problem - it would be interpreted as 2 variables or field names. Peter's "if" statement works in the client-side properties, calculated field expression - you're allowed the nested if statements in there - it gets converted to the equivalent javascript nested if statement.
    I tried it exactly as described, and I still get the error (please see attached image).

  14. #14
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,670

    Default Re: calculated field expression

    Now we need to find out what M_filter, M_filter_oil_price, M_filter_air_price, and M_filter_fuel_price are, Are these calculations that reference themselves? A circular reference is a variable, field, etc. that references itself in the calculation thereby creating a reference that goes around and around in a circle and can never be evaluated.

  15. #15
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,355

    Default Re: calculated field expression

    Quote Originally Posted by Davidk View Post
    Now we need to find out what M_filter, M_filter_oil_price, M_filter_air_price, and M_filter_fuel_price are, Are these calculations that reference themselves? A circular reference is a variable, field, etc. that references itself in the calculation thereby creating a reference that goes around and around in a circle and can never be evaluated.
    They are fields.

  16. #16
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,670

    Default Re: calculated field expression

    In your last image showing the error you had an extra ending paren ")" but that would produce an evaluation error. Which field is this calculation attached to?

  17. #17
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,355

    Default Re: calculated field expression

    The price field.

  18. #18
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,670

    Default Re: calculated field expression

    It's PRICE!!! Had to create the table and and grid and just start typing the calc.

    Yikes... that was a weird one.

    The moment you type if(M_Filter="Oil',M_Filter_Oil_Price... you get the error. For some reason A5 is seeing the work Price and is parsing it, recognizing it as the field itself.

    I changed the fieldname to MPrice and all is well.

Similar Threads

  1. Calculated field expression
    By envisionsolutions in forum Application Server Version 10 - Web/Browser Applications
    Replies: 0
    Last Post: 10-15-2010, 05:13 PM
  2. Calculated field expression
    By steinmanal in forum Alpha Five Version 7
    Replies: 1
    Last Post: 01-29-2007, 01:19 PM
  3. calculated field expression
    By EDDYSOL37 in forum Alpha Five Version 7
    Replies: 9
    Last Post: 08-01-2006, 12:51 PM
  4. Need help with calculated field expression
    By Charlain in forum Alpha Five Version 5
    Replies: 4
    Last Post: 12-02-2002, 05:12 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
  •