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
bclapperbclapper 

Aggregate List Question

I wrote a controller extension to create an aggregate list but I want to include a field that is neither an aggregate field or a group by field.  I have a custom object called Comm Rec and a child called Order Entry.  On the Order Entry I have a Sales Rep, Invoice Number, Invoice Date, Sales & Comm field.  I wrote the aggregate list to SUM the Sales & Comm fields and Group by Rollup on the Sales Rep, Invoice Number fields.  This works and displays the information as you would expect but I need to display the Invoice Date as well.  What would be the best way to go about it?

sfdcfoxsfdcfox
You can't have a non-aggregated, non-grouped field in an aggregate query. This is because each grouping creates only one row of data in the result set, and a non-grouped, non-aggregated value could violate that constraint. Grouping by rollup allows you to have a list that includes grand totals and subtotals. If all dates in a single aggregate row would be the same, then grouping by the date field will have no additional effect. Otherwise, if there could be multiple dates, but you don't want to group by date, then you'll have to use a min or max function to return just a single date from all possible result sets for that subtotal category.
bclapperbclapper

Would there be a way then to create a normal list and use the <apex repeat> to a subtotal to the Sales & Comm fields?

bclapperbclapper

Sorry, there are multiple dates that I don't want to aggregate, I just want to display the Invoice Date along with all the other values.