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
MultimanMultiman 

Create a roll-up sum of all items in a pageBlockTable column

Hi

how can I create and render the total amount of all values that are displayed in a certain column of a pageBlockTable ?

Since VF iterates over a set of objects there should be a way to do that without a custom controller.

 

Any hint is appreciated.

Thanks

Alex

Pradeep_NavatarPradeep_Navatar

In my opinion, you can use Aggregate function in controller or some business logic about total sum.

 

AggregateResult[] groupedResults = [SELECT SUM(Amount)aver FROM Opportunity];

 

Hope this helps.

MultimanMultiman

I found this solution which I would like to share

 

 

<apex:variable value="{!0}" var="MaxDocCount"/>

<apex:repeat var="rep" value="{!account.Repositories__r}">

<apex:variable var="MaxDocCount" value="{!IF(TEXT(rep.CR_Number_of_k_Docs__c) = '', MaxDocCount, MaxDocCount + rep.CR_Number_of_k_Docs__c)}"/>

</apex:repeat>

 

The if function is used to skip items with an empty doc count value. So you can do that without a custom controller.