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:
This results:
To sum all the the Amount, i add this,
And i get the result:
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.
Hi Mohsin Abbas,
I managed to solve my problem. I did not use "repeat" and "Until", only the trigger OnAfterGetRecord().
I just added another dataitem to hold the TotalAmount like these:
trigger OnAfterGetRecord()
begin
TotalAmount += Amount;
end;
dataitem(Total; Integer)
{
MaxIteration = 1;
column(TotalAmount; TotalAmount)
{
}
}
Your dataset is okay but needs a little tweak for working with Word Layout. The issue is, when you put the TotalAmount field in layout, it takes the first value only. So you need to manipulate the dataset in such a way that the all the rows contain the overall total rather than the running total. You can include an Integer dataitem as the 1st datitem and Calculate the total by code. In this way, all of your rows will have the same value for TotalAmount i.e. the overall total.
See the below screenshot and let me know if this helps.
.
Actually, i wanted to use RDLC layout since it is much easier there i guess, but then im using Word layout.
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.
Hi Mohsin Abbas,
This code triggered in report object.
This is my code.
I got this result, i just snipped the last page of the report. With this it just get the first Amount record.
I just wanted to sum all the Amount column of the report. How do i acheive it? How do i get the total Amount?
In which trigger are you writing this code?
Hi Mohsin,
I tried it, and it just get the first row Amount of the MainItem.
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.
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.
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,900 Super User 2024 Season 2
Martin Dráb 229,297 Most Valuable Professional
nmaenpaa 101,156