Hello.
This is a field from my database that I have successfully display it into webpage.
The question is how do it do to calculate total sum of the field (calculate sum of every row on that field)?
Does it need to be done in srvroutine or in evtroutine at webpage?
Please help.
Regards
Sum Cclculation in Lansa
Re: Sum Cclculation in Lansa
Whether you do this on the server or on the client does not matter.
You can
a) do it on the server and return the sum
or
b) do the sum in the browser
So you have the values in a list. Simply spin the list and accumulate the sum.
#sum := 0
Selectlist #listname
#sum += #yourfield
endselect
Now #sum has the total.
You can
a) do it on the server and return the sum
or
b) do the sum in the browser
So you have the values in a list. Simply spin the list and accumulate the sum.
#sum := 0
Selectlist #listname
#sum += #yourfield
endselect
Now #sum has the total.
-
HamadSheikh
- Posts: 27
- Joined: Fri Mar 18, 2016 3:49 am
- Location: USA
- Contact:
Re: Sum Cclculation in Lansa
Just before your Add_Entry line, where you add your entry into your list, you can accumulate your total e.g.
#TotalField := #TotalField + #NumFieldFromList
After you are done populating the list, your #TotalField will contain the sum of all #NumFieldFromList entries.
Don't forget to reset #TotalField to zero before each list gets built.
#TotalField := #TotalField + #NumFieldFromList
After you are done populating the list, your #TotalField will contain the sum of all #NumFieldFromList entries.
Don't forget to reset #TotalField to zero before each list gets built.