442
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
2022-10-17 06-51-09
Shweta Gedam
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 :)

UserImage.jpg
Golden Daffodil

Hi  Shweta Gedam,

Thanks for expalnation.

I'm  just trying according to your explanation.But I want to know one thing that is  when I do expression ,how can I  get CalculateTotalPrice function ?

 

Hayasaka

2022-10-17 06-51-09
Shweta Gedam

Hi Hayasaka,

CalculateTotalPrice is a server action i have created inside Logic Tab-> Server Actions folder which is marked as a function and you can use this function inside expression from UserFunctions folder (Provided Screenshot).

Please refer following screenshot:


I have attached an OML file for reference of implementation.

Thanks and Happy Coding .


SumOfTotal.oml
UserImage.jpg
Golden Daffodil

Hi Shweta Gedam,

Your explanation was really perfect.It does work ! Thanks you so much .

Hayaska

50.png
2022-10-17 06-51-09
Shweta Gedam

Great!! Welcome Hayasaka , i'm always happy to help.

Thanks and Happy Coding :)

2020-06-04 15-38-19
Samiksha Manekar

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

UserImage.jpg
Golden Daffodil

Hi Samiksha,

I tried according to your explanation.Unfortunately,it didn't work. 

Thank for your comment and hoping you can solve my next time issues.

Hayasaka

2022-10-17 06-51-09
Shweta Gedam
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 :)

UserImage.jpg
Golden Daffodil

Hi  Shweta Gedam,

Thanks for expalnation.

I'm  just trying according to your explanation.But I want to know one thing that is  when I do expression ,how can I  get CalculateTotalPrice function ?

 

Hayasaka

2022-10-17 06-51-09
Shweta Gedam

Hi Hayasaka,

CalculateTotalPrice is a server action i have created inside Logic Tab-> Server Actions folder which is marked as a function and you can use this function inside expression from UserFunctions folder (Provided Screenshot).

Please refer following screenshot:


I have attached an OML file for reference of implementation.

Thanks and Happy Coding .


SumOfTotal.oml
UserImage.jpg
Golden Daffodil

Hi Shweta Gedam,

Your explanation was really perfect.It does work ! Thanks you so much .

Hayaska

50.png
2022-10-17 06-51-09
Shweta Gedam

Great!! Welcome Hayasaka , i'm always happy to help.

Thanks and Happy Coding :)

2020-09-21 11-35-56
Sachin Waghmare

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

UserImage.jpg
Golden Daffodil

Hi Sachin ,

Thanks for your suggestion. I achieved with another way. 

Hayaska

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.