web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Get the Total Amount by calculating the Amount column from Cust. Ledger Entry to create a report.

(0) ShareShare
ReportReport
Posted on by 90

Hi All,

Im new to Business Central al programming and i was tasked to make a report. In the report i was able to list down the invoices of a customer. So my problem is how sum the Amount column to get the total amount. Also, i am able to sum all the amount, but then it ended up having 1 record of invoice. So, im doing it wrong, can you please help to me setup this correctly. Thanks. Here is how i do it:

4807.PNG

This results:
2526.PNG

To sum all the the Amount, i add this,

3884.PNG

And i get the result:

5241.PNG

I guess, i was able to sum the Amount, but i ended having one record.

So, how i set this up so I can get all records as well as the Total Amount? or if this is another way to achieve this, i need guide

Thank you.

I have the same question (0)
  • Thomas Vetrugno Profile Picture
    30 on at

    Hi Lino,

    the trigger called OnAfterGetRecord runs each time a record is retrieved from the data item.

    In your case, for each record from cust. ledger entry, your are looping again through entire table. You have to remove the 'repeat until' and the report should works

  • Lino Asmolo Jr Profile Picture
    90 on at

    Hi Thomas Vetrugno,

    Thanks for your reply.

    You mean like this?

    trigger OnAfterGetRecord()
             begin
                    if MainItem.FindSet(false, false) then
                        TotalAmount := TotalAmount + MainItem.Amount;
    end;
    I tried it and i got this result when running the report:
    7345.PNG
    Am i doing it correctly, because the Rows generated: 14242, doesnt stop increasing in number
  • THE Italian Profile Picture
    Microsoft Employee on at

    This should be enough

    trigger OnAfterGetRecord()
             begin
                        TotalAmount := TotalAmount + Amount;
    end;
  • Lino Asmolo Jr Profile Picture
    90 on at

    Hi @Duilio Tacconi,

    This one doesn't solve my problem, i tried it and the result is, it listed the rows but then the Total Amount field is 0 again.

  • Suggested answer
    Mohsin Abbas Profile Picture
    525 on at

    Hi Lino

    Please note that Amount is a flowField flowField so you'll need to do CalcFields(Amount) to get the value of amount. Otherwise it'll always come as 0.

  • Mohsin Abbas Profile Picture
    525 on at

    Hi Lino

    Please note that Amount is a FlowField so you'll need to do CalcFields(Amount) to get the value of amount. Otherwise it'll always come as 0.

  • Lino Asmolo Jr Profile Picture
    90 on at

    Hi Mohsin,

    I tried it, and it just get the first row Amount of the MainItem.

  • Mohsin Abbas Profile Picture
    525 on at

    In which trigger are you writing this code?

  • Lino Asmolo Jr Profile Picture
    90 on at

    Hi Mohsin Abbas,

    This code triggered in report object.

    This is my code.

    23.PNG

    I got this result, i just snipped the last page of the report. With this it just get the first Amount record.

    6558.Capture1.PNG

    I just wanted to sum all the Amount column of the report. How do i acheive it? How do i get the total Amount?

  • Suggested answer
    Mohsin Abbas Profile Picture
    525 on at

    There are multiple ways to do that:

    1.  CurrReport.CreateTotals in OnPreDataItem Trigger(docs.microsoft.com/.../createtotals-function--report-)  

    2.  In RDLC Layout, simply add a field for sum(Amount) it will give you the total.
    6036.Untitled.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 572 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 331 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 330 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans