Calculate total programatically

foxclubfoxclub Member Posts: 16
Hello. Please I need to calculate the total of quantity in report "transfer shipment" by c/al code.
Give me an idea.
I am using dynamics nav 2018 v11.

Answers

  • RockWithNAVRockWithNAV Member Posts: 1,139
    And thats totally depends on the grouping of your Report like how you have maintained it.
  • foxclubfoxclub Member Posts: 16
    Hello,

    =sum(Fields!Qty_TransShptLine.Value)

    This is how i calculated the total quantity in "transfer shipment" report.
    Unfortunately sum obtained was wrong.
  • omyvadiyaomyvadiya Member Posts: 124
    when you see the Report preview, go to About this report and export the data in excel and check where is the correct value is coming & use last instead of sum if correct value is in the last row or if the correct value is the first value then use the first instead sum.
    if the value is coming somewhere in between, then you have to write code on the onaftergetrecord of the record and have to use that variable's sum or last in the rdlc expression.
  • foxclubfoxclub Member Posts: 16

    using last or first instead of sum did not work. Then how please could I use that by code.
    I tried in OnAfterGetRecord():
    totQty:="Transfer Shipment Line".Quantity;
    However no result.
  • wolfskinwolfskin Member Posts: 84
    foxclub wrote: »
    using last or first instead of sum did not work. Then how please could I use that by code.
    I tried in OnAfterGetRecord():
    totQty:="Transfer Shipment Line".Quantity;
    However no result.

    In case of you want to use a variable to accumulate the values please try this code
    totQty += "Transfer Shipment Line".Quantity;
    

    Never forget to clear your variable every time the grouping key is changed.
Sign In or Register to comment.