How show the maximum and minimum values

markyTmarkyT Member Posts: 120
Hello, I've a report that shows simply list of registers from "Item Ledger Entry" table. One of this fields is "Invoice quantity" field. I want to show, in a footer section, the maximum and minimum value from the this field from those shown. How it would the code to do this, please?.
Thanks in advance.

Comments

  • suvidhasuvidha Member Posts: 117
    Hi,
    I don't think there is any function or a property which can get the maximum value. :-k
    The Only way is to check the "Invoiced Quantity" onaftergetrecord() every time and keep the highest in a variable and display it at the end. :roll:
  • markyTmarkyT Member Posts: 120
    Thanks for reply; what you're proposing would be enough for me. Can you explain me how I can do that by code, please?.
    Thanks.
  • suvidhasuvidha Member Posts: 117
    Simple..

    Define Variable Qty of type Decimal.
    Initialize Qty:=0;

    onAfterGetrecord()
    IF Qty < "invoiced Quantity" THEN
    Qty:= "invoiced Quantity";

    Display Qty in Footer.
  • kapamaroukapamarou Member Posts: 1,152
    suvidha wrote:
    Initialize Qty:=0;

    onAfterGetrecord()
    IF Qty < "invoiced Quantity" THEN
    Qty:= "invoiced Quantity";

    Just be careful how you handle Negative Values if they exist... :wink:
  • MaximusMaximus Member Posts: 105
    Hi,

    could be solved with a Key with Invoiced Quantity as first field. Used in Tables 266, 267 and 268. Use FINDFIRST or FINDLAST in code to get the Min and Max values.

    Or you could use GETRANGEMIN and GETRANGEMAX in code when you filtered out the recordset. See Help for details on these functions.

    Finally a flowfield could be used with Min or Max in the CalcFormula.
  • suvidhasuvidha Member Posts: 117
    edited 2009-11-16
    kapamarou wrote:
    suvidha wrote:
    Initialize Qty:=0;

    onAfterGetrecord()
    IF Qty < "invoiced Quantity" THEN
    Qty:= "invoiced Quantity";

    Just be careful how you handle Negative Values if they exist... :wink:


    Yeah right.... :!:
    For maximum Inv Qty ...

    onAfterGetrecord()
    IF Qty=0 THEN
    Qty := "invoiced Quantity"
    ELSE IF Qty < "invoiced Quantity" THEN
    Qty:= "invoiced Quantity";


    For mimimum Inv Qty....
    onAfterGetrecord()
    IF Qty1=0 THEN
    Qty1 := "invoiced Quantity"
    ELSE IF Qty1 > "invoiced Quantity" THEN
    Qty1:= "invoiced Quantity";

    Hope u dont find ILEs with Invoiced Quantity = 0 !!!!
  • markyTmarkyT Member Posts: 120
    Thanks for reply but the code:

    Initialize Qty:=0;
    onAfterGetrecord()
    IF Qty < "invoiced Quantity" THEN
    Qty:= "invoiced Quantity";

    Doesn't runs well, It gave me the last register, not the minimum; any idea please?
  • markyTmarkyT Member Posts: 120
    Sorry so much, I've forgotten to inicialite the Qty. It runs perfectly. Thanks everybody for help.
  • philippegirodphilippegirod Member Posts: 191
    Flowfield:
    CalcFormula = Min(MyTable.MyField) or
    CalcFormula = Max(MyTable.MyField)
    My candle burns by both ends, it will not last the night,
    But oh my foes and oh my friends, it gives a lovely light
Sign In or Register to comment.