Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Question about percents

edited June 2003 in General
Hi! everybody

I hope that anyone can help me, I need build a report like the next

WAREHOUSE 1
------------------------------------
| ORANGES | 4 | 20% |
------------------------------------
| LEMONS | 6 | 30% |
------------------------------------
| TOMATOES | 10 | 50% |
------------------------------------
| TOTAL | 20 | 100% |
------------------------------------

The problem here is how can I calculate de percent over the amoung, any
sugestion?.

thanks in advance.

Comments

  • edited June 2003
    You need a TwoPass Report that will keep a stringlist with all totals ion
    the first pass, so you could access it in the second pass.

    procedure Variable3OnCalc(var Value: variant);
    var
    ldTotal: Double;
    begin
    if Report.SecondPass then
    begin
    ldTotal := StrToFloat(TotalSales[Group1.BreakNo]);
    if (ldTotal > 0) then
    Value := (100/ldTotal)*DBText2.FieldValue
    else
    Value := 0;
    end;
    end;

    procedure GroupFooterBeforePrint
    begin
    if Report.FirstPass then
    TotalSales.Add(FloatToStr(DBCalc1.Value));
    end;

    HTH

    -Jack

  • edited June 2003

    Another approach is to use RB's LookAhead feature to accomplsh this. Below
    is an example that you can download

    http://www.digital-metaphors.com/tips/UseLookAheadValueInCalc.zip



    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.