web
You’re offline. This is a read only version of the page.
close
Skip to main content
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 80

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
    RE: Get the Total Amount by calculating the Amount column from Cust. Ledger Entry to create a report.

    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
    80 on at
    RE: Get the Total Amount by calculating the Amount column from Cust. Ledger Entry to create a report.

    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
    on at
    RE: Get the Total Amount by calculating the Amount column from Cust. Ledger Entry to create a report.

    This should be enough

    trigger OnAfterGetRecord()
             begin
                        TotalAmount := TotalAmount + Amount;
    end;
  • Lino Asmolo Jr Profile Picture
    80 on at
    RE: Get the Total Amount by calculating the Amount column from Cust. Ledger Entry to create a report.

    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
    RE: Get the Total Amount by calculating the Amount column from Cust. Ledger Entry to create a report.

    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
    RE: Get the Total Amount by calculating the Amount column from Cust. Ledger Entry to create a report.

    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
    80 on at
    RE: Get the Total Amount by calculating the Amount column from Cust. Ledger Entry to create a report.

    Hi Mohsin,

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

  • Mohsin Abbas Profile Picture
    525 on at
    RE: Get the Total Amount by calculating the Amount column from Cust. Ledger Entry to create a report.

    In which trigger are you writing this code?

  • Lino Asmolo Jr Profile Picture
    80 on at
    RE: Get the Total Amount by calculating the Amount column from Cust. Ledger Entry to create a report.

    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
    RE: Get the Total Amount by calculating the Amount column from Cust. Ledger Entry to create a report.

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 3,750

#2
Sumit Singh Profile Picture

Sumit Singh 2,689

#3
YUN ZHU Profile Picture

YUN ZHU 1,987 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans