function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How do I add a total line to a column in VF?

I need to add a total line for the sales amount on a VF page.


How do I do this when I am returning a list of accounts from my controller?


Shiv ShankarShiv Shankar

 We can do it with two ways

1. iterate over the list and calculate the amount and display total property on VF Page.

2.Using <apex:variable> in VF Page.


	<apex:variable name="total" value="{! 0}" />
	<apex:repeat var="rec" value="{! yourList}">
		<apex:variable name="total" value="{! total+rec.Amount}" />
	<apex:outputtext value="{! total}">