29
Views
9
Comments
Solved
How to calculate SUM of Total Amount
Application Type
Traditional Web

I'm  developing application for traditional web.I have database GetMain , where I have many attributes (Date, ProductPrice, SalesAmount, TotalPrice) .My problem is need to calculate  total price with previous salesAmount .

(SalesAmount)Total
16,79816,798
30,63447,432
27,90475,336

For example, if I get SaleAmount ,I want to sum previous total price and only one thing that is automatic calculate in total  attribute.

Thanks . Hoping good result.

Hayasaka

20LI.jpg

Rank: #292
Solution

Hi Hayasaka,

What you can do is to create a server action with input SalesAmount and Total as the output parameter and also one session variable as SalesAmountTotal with default value 0 and mark the server action as function.

In that server action, add an assignment as Total = SalesAmount + SalesAmountTotal. and SalesAmountTotal = Total


Use this inline function inside your Total column in screen. 

NOTE: Don't forget to assign SalesAmountTotal session variable to 0 in preparation as the value persists till session is valid

I'm getting the desired result as below:

Hope this helps! Thanks :)

Hi Hayasaka,

we have new attribute option in aggregate .In the new attribute you can calculate  Sales attribute + Total price:

For example


Hope this Helps.

Regards

Samiksha

Rank: #292
Solution

Hi Hayasaka,

What you can do is to create a server action with input SalesAmount and Total as the output parameter and also one session variable as SalesAmountTotal with default value 0 and mark the server action as function.

In that server action, add an assignment as Total = SalesAmount + SalesAmountTotal. and SalesAmountTotal = Total


Use this inline function inside your Total column in screen. 

NOTE: Don't forget to assign SalesAmountTotal session variable to 0 in preparation as the value persists till session is valid

I'm getting the desired result as below:

Hope this helps! Thanks :)

Rank: #420

Hi Hayasaka,

It would be better to give a try with Advance SQL query to add the previous value with the current value. Please see sample query.

Select *, Sum(SalesAmount) Over ( Order by Date ) As CumSum_ByDate
From {yourEnitityName}

Thanks & Regards,

Sachin