New call-to-action
Results 1 to 7 of 7

Thread: If..Then.. function in a report

  1. #1
    Member
    Real Name
    Denis Ahmet
    Join Date
    Jul 2005
    Location
    United Kingdom
    Posts
    988

    Default If..Then.. function in a report

    I think this one should be straight forward, but i cannot find anything in the forum which directly addresses my request.

    Basically, i have two numerical fields in my report.

    field 1: Quantity
    field 2: Cost

    I wish to put in place a calculation which determines the cost depending on the quantity. e.g.

    0 - 999 = 100.00
    1000 - 3999 = 200.00
    4000 - 7999 = 300.00
    8000 - 11999 = 400.00
    12000 and above = 500.00

    Can anyone tell me how i can achieve this?

    As always, thanks in advance.

    Denis

  2. #2
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,785

    Default Re: If..Then.. function in a report

    Code:
    case(Quantity<1000,100.00,Quantity<4000,200.00,Quantity<8000,300.00,Quantity<12000,400.00,.t.,500.00)
    The case statement uses the first true statement from the left. The last test is .t. which acts as a default if all the previous tests fail.
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  3. #3
    Member
    Real Name
    Denis Ahmet
    Join Date
    Jul 2005
    Location
    United Kingdom
    Posts
    988

    Default Re: If..Then.. function in a report

    Tim,

    Thank you for the speedy response. This bit of Alpha is new to me, can you tell me where the case statement should be placed.

    Thanks again.

    Denis

  4. #4
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,785

    Default Re: If..Then.. function in a report

    Quote Originally Posted by den1s View Post
    Tim,

    Thank you for the speedy response. This bit of Alpha is new to me, can you tell me where the case statement should be placed.

    Thanks again.

    Denis
    Denis,

    with the report in design mode click the xy button on the main alpha toolbar. This opens the Calculated values dialog. Enter a new line containing "cost =" (no quotes) and the expression from the previous post. Or enter "cost =' and press f10 to invoke the expresion builder where you can build the expression. After entering press OK until you are back to the form design.

    Then from the drag drop list choose the newly created calculation and place it into the detail section of the report.
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  5. #5
    Member
    Real Name
    Denis Ahmet
    Join Date
    Jul 2005
    Location
    United Kingdom
    Posts
    988

    Default Re: If..Then.. function in a report

    Quick, Slick, Perfect!!!

    Thank you.

  6. #6
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,785

    Default Re: If..Then.. function in a report

    Quote Originally Posted by den1s View Post
    Quick, Slick, Perfect!!!

    Thank you.
    Your welcome. The fact you are Alpha fiving hopefully means you don't need to be outside sand bagging your house. :)
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  7. #7
    Member
    Real Name
    Denis Ahmet
    Join Date
    Jul 2005
    Location
    United Kingdom
    Posts
    988

    Default Re: If..Then.. function in a report

    We were lucky in London as we escaped the worst of it. So far....

Similar Threads

  1. Using lookup() function in report
    By trackmanpete in forum Alpha Five Version 8
    Replies: 2
    Last Post: 03-09-2007, 08:33 PM
  2. Report email function
    By p. crane in forum Alpha Five Version 6
    Replies: 10
    Last Post: 03-10-2005, 03:46 PM
  3. Report - Total Function
    By Jonathan Short in forum Alpha Five Version 6
    Replies: 1
    Last Post: 02-16-2005, 12:47 PM
  4. Report.send function
    By Anis in forum Alpha Five Version 5
    Replies: 4
    Last Post: 04-05-2004, 12:02 PM
  5. Report Format Function (B-) Not Working Properly
    By Michelle in forum Alpha Four Versions 7 and 8
    Replies: 1
    Last Post: 11-21-2002, 10:11 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
  •