How to make variable calculations in a Report.

frandigofrandigo Member Posts: 1
Hi guys I'm new here ...i have a doubt i have to make some vars calcs in a report
and i have to show vars in each DataItem customer process. I think i dont need CREATETOTAL NAV Function beacuse vars are not in FOOTER or GROUP Sections,
so I need help to make calcs. Here's the code..thanks.

Salesperson/Purchaser - OnAfterGetRecord()

SalesPersonCode := Code;

Customer - OnAfterGetRecord()
TotalMCurrYear := 0;
TotalMPrevYear := 0;

recSalesInvHeader.RESET;
recSalesInvHeader.SETRANGE("Sell-to Customer No.", "No.");
recSalesInvHeader.SETRANGE("Salesperson Code", SalesPersonCode);
recSalesInvHeader.SETFILTER("Due Date", '%1..%2', FInicio, FFin);
IF recSalesInvHeader.FINDSET THEN BEGIN
REPEAT
recSalesInvLine.RESET;
recSalesInvLine.SETRANGE("Document No.", recSalesInvHeader."No.");
IF recSalesInvLine.FINDSET THEN
REPEAT
TotalMCurrYear += recSalesInvLine.Amount;
UNTIL recSalesInvLine.NEXT = 0;
UNTIL recSalesInvHeader.NEXT = 0;
END;

recSalesInvHeader.RESET;
recSalesInvHeader.SETRANGE("Sell-to Customer No.", "No.");
recSalesInvHeader.SETRANGE("Salesperson Code", SalesPersonCode);
recSalesInvHeader.SETFILTER("Due Date", '%1..%2', FInicioPrevYear, FFinPrevYear);
IF recSalesInvHeader.FINDSET THEN BEGIN
REPEAT
recSalesInvLine.RESET;
recSalesInvLine.SETRANGE("Document No.", recSalesInvHeader."No.");
IF recSalesInvLine.FINDSET THEN
REPEAT
TotalMPrevYear += recSalesInvLine.Amount;
UNTIL recSalesInvLine.NEXT = 0;
UNTIL recSalesInvHeader.NEXT = 0;
END;

Answers

  • nizar_mneimnehnizar_mneimneh Member Posts: 3
    Hello, ive been there before, actually u have 2 ways you can calculate totals in rdlc reports
    In both cases u have to add a new row at the end for totals.
    First one is that you have to right click the cell go to expression and write sum(recSalesInvLine.Amount) which will do the summation for u
    Second one is that you write LAST(TotalMPrevYear) which will get u the last value saved for this var
    Best of luck
  • lubostlubost Member Posts: 611
    Use query for create totals ... it is much faster and efficient.
Sign In or Register to comment.