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

Variables not Calcing

edited June 2002 in General
Greetings,
I have a report grouped by salesman.

I have followed the Percent of GroupTotal example to the T.

Basically it's an Accounts Receivable Aging by Salesman report and I'm
taking each of the aging values and dividing it by the total receivable for
the salesman to come up w/ a percent.
I use variables to calc the Percents.

All works perfectly EXCEPT for two salesmen that fall in the middle of the
report.

All other salesmen percents calc out perfectly except these two.

I've gone into debug and the numbers look right, just seems the VALUE
variable does not get assigned.

Any help here would be GREATLY appreciated.

Kevin Stanton
RDB Solutions

Comments

  • edited June 2002
    Since the calculation work for most of the record it isn't likely that that
    is where the problem lies. One thing to check would be the DisplayFormat of
    the variable. It is possible that the percentages are coming out small
    enough that they are being truncated to 0.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited June 2002
    I wish it were that easy!
    I checked this once, but I will reverify.

    The datatype is dtDouble.
    Displayformat = ##0.00 % (I even tried removing this altogether).
    I have just tried using a ppLabel and it shows just fine.
    Here is the code:

    procedure TrbARAgingDetail.varTPct1Calc(Sender: TObject;
    var Value: Variant);
    var
    liIndex: Integer;
    FullName : String;
    Tot, Amt : Integer;
    Pct : Double;
    begin
    if (ppReport1.SecondPass) then
    begin
    FullName := qryOpenInvFullName.AsString; // this is just for
    debugging so I could stop on the saleman's name
    liIndex := grpTrader.BreakNo;
    Tot := Integer(FTraderTotals0[liIndex]);
    Amt := Integer(FTraderTotals1[liIndex]);

    If (Integer(FTraderTotals0[liIndex]) <> 0) and
    (Integer(FTraderTotals1[liIndex]) <> 0) then
    begin
    // Value := (Integer(FTraderTotals1[liIndex]) /
    Integer(FTraderTotals0[liIndex])) * 100
    Pct := (Amt / Tot) * 100;
    Value := Pct;
    lblPctT1.Caption := Format('%5.2f', [Pct]) + '%'; // this was
    just added and the Caption shows the correct %: 16.13
    end
    else
    Value := 0;
    end // if ppReport1.SecondPass
    end

    Thanks for the reply!
    Kevin



    "Alexander Kramnik (Digital Metaphors)" wrote
  • edited June 2002
    Try changing the line

    Pct := (Amt / Tot) * 100;

    to

    Pct := (Double(Amt) /(Double( Tot)) * 100.0;

    because it is probably performing integer division.


    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

This discussion has been closed.