Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [aggregateresult]

The tag has no usage guidance, but it has a tag wiki.

3
votes
2answers
46 views

Getting AggregateResult variables from Execute Anonymous Window

I am trying to execute a block of code using the Execute Anonymous Window that is meant to delete some duplicated data, but I am getting this weird error about a variable not existing even though my ...
0
votes
1answer
32 views

Error: BillingAddress does not support aggregate operator COUNT

I am trying to get a list of Accounts that has the same BillingAddress I tried to get an aggregateResult however got the error: Line: 2, Column: 34 HAVING count(BillingAddress)>1 ^ ERROR at ...
0
votes
1answer
23 views

Merge lists to get a good overview

I have two objects (one custom object "sales", two standard object "opportunity" and "account") and I have three lists with aggregateresults. Can I merge these lists into one list? The goal of the ...
0
votes
1answer
33 views

Error : Attempt to de-reference a null object ; on map variable

Class.ResourceProfileController.__sfdc_mapSummary: line 137, column 1 Class.ResourceProfileController.__sfdc_listWrapperEmployee: line 162, column 1 --> Error on the Variable mapSummary Hello I'm ...
0
votes
1answer
19 views

Want to fetch field from AggregateQuery

I created a Custom Settings and add some records in it. On the basis of that value i write an aggregate query and i want to store that field value in String. // List to fetch all records from ...
0
votes
1answer
38 views

Aggregate SOQL Query Cannot Aggregate

In my Product Object there is a list of ProductMatrices. I want to total sum of matrices field. So for that i used Aggregate soql. But its not showing aggregate result. public List<AggregateResult&...
0
votes
1answer
46 views

Is it possible to output an aggregate query to a Map<Id, List<Contact>>

Is it possible to output an aggregate query like this: Map<Id, List<Contact>> accountContactsMap = [SELECT aggregate query ...]; Where the Map key is the AccountId and the Map value is a ...
0
votes
1answer
29 views

Two Aggregate Results in one list (continue)

This post is the continue from here. David told me it is better to start a new post. My class is fine so far, I get no error. But if I try to display the results, I get an error "Unknown property '...
1
vote
1answer
40 views

APEX Aggregate Result vs Repeat with Variable

I am trying to sum a value from a list of records. I can achieve this by creating a list in APEX, then represent the list on a Visualforce page without rendering any fields. I have also done this by ...
3
votes
1answer
99 views

Select aggregate into Integer using Database.query()

So we all know we can put an aggregate directly into an Integer, like this: Integer countAccounts = [SELECT COUNT() FROM Account]; Is it possible to do the same thing, using Database.query()? ...
0
votes
1answer
50 views

How to get Map<Id, List<Contact>> from Contact SOQL query GROUP BY AccountId

How could I get this object Map<Id, List<Contact>> Using an SOQL query similar to this: Map<Id, List<Contact>> contactMap = new Map<Id, List<Contact>>( ...
0
votes
1answer
65 views

Two Aggregate Results in one list

I've changed the code again, but I still get an error. But now I get the error: Constructor not defined: [VTP31_class.CombinedSummary].(AggregateResult, AggregateResult) in row 35, column 35 CLASS ...
6
votes
1answer
256 views

SOQL AggregateResult Query throws error: System.ListException: Row with null Id at index: 0

Background I have this Apex SOQL query: myMap = new Map<Id, AggregateResult>([SELECT OpportunityLineItemId, MIN(ScheduleDate) Starts ...
0
votes
1answer
37 views

AggregateResult Show Percent of one variable out of another

How can I create a variable for the aggregateresult addedserviceresults that would show in a Visualforce table as a column % for each Franchise_Added_Service__r.Group__c out of the value from a second ...
-1
votes
1answer
49 views

How to Calculate a Percent in an AggregateResult Method

I am using a custom controller for a Visualforce page on a custom object (Quote__c). I have an AggregateResult method that sums 3 amount fields to show grand totals on my VF page. I would like to add ...
0
votes
1answer
71 views

AggregateResult Grand Total on VF Page

I have a custom VF controller that uses the AggregateResult method to summarize some fields by year. All that works as expected, but now I want to also pull the total for each metric field for all ...
1
vote
1answer
57 views

Aggregate Result returning 1 product only

I am getting a sum but what happens is that it only sums up one products instead of the total number of products Map<String, List<aggregateresult>> MapStringListaggregateresultSAA = new ...
0
votes
0answers
33 views

Null Value for record after getting id from a map of ids and accounts

The system.debug shows that the id for TempAcct is associated with the correct id after a.get('Franchise__c'), but NewAcct = null. The debug shows that the id was mapped correctly to filterIds, and it'...
0
votes
1answer
152 views

Illegal assignment from list to list for custom class and aggregateResult

I have a custom controller and visualforce page. The page loads fine with the SummaryList. When the user enters parameters, it should filter the list according to the runSearch method. I'm getting an ...
0
votes
1answer
39 views

Javascript Filter In Custom Controller Not Returning Filtered Results to Visualforce Page

I have a custom controller and page with a few lines of Javascript. The functionality should work as follows: when a user enters a state or account name in the parameters, the list of accounts and ...
0
votes
1answer
48 views

Filter for Aggregated List Results in Custom Controller

I have a custom controller with a Visualforce page that displays a list of accounts with aggregated results for each account. I want to create a filter for state and inspection date that would filter ...
0
votes
2answers
42 views

Combining SOQL Queries

I need to pull out a query that fetches: From My Team object and Package object. Package is a child of Teams From teams I need to pull how many packages is currently in teams and how much each ...
3
votes
1answer
559 views

Compile Error: Method does not exist or incorrect signature void add(AggregateResult)

My full error message is as follows Error: Compile Error: Method does not exist or incorrect signature: void add(AggregateResult) from the type List at line 21 column 41 I am working on building a ...
1
vote
2answers
140 views

How to get aggregate results from generic map?

How can I get the Orders values from the following generic map? Map<Id, Account> ordersByAccountIdMap = new Map<Id, Account>([SELECT Id, (SELECT Id FROM Orders) FROM Account]); Map<Id,...
1
vote
1answer
117 views

Can I manipulate the List of AggregateResult returned in a SOQL Query?

Recently I worked on a requirement where I had to return List after adding results from 2 different queries in specific format because the managed class method overriding only returns list of objects. ...
1
vote
2answers
156 views

Aggregate result delete issue in trigger

Requirement : There is rollup (Sum) between opportunity and opportunitylineitem. Insert and update event is working fine but for delete event is not working correct. I have one opportunity and one ...
1
vote
2answers
79 views

count number of cases in a consecutive date range

I have a requirement to keep a count of previous cases that were closed consecutively within 24hr periods on the latest closed case pseudo logic would be something like this: trigger when case is ...
0
votes
1answer
691 views

Aggregated Query Too many query rows

I have this aggregated query which seems to return only 1050 rows but still I am getting a limit exception. This is the APEX query: AggregateResult[] groupedResults = [SELECT COUNT_DISTINCT(ID) cnt, ...
2
votes
2answers
1k views

How to read field values from AggregateResult

I need to use group by cube to display the count of added services for each group for each package. I get an error on line 18: method does not exist or incorrect signature: void get(String) from the ...
2
votes
1answer
230 views

Use SOQL aggregation result to count number of related objects

I have a fun puzzle here, and would like to see if anyone has a better solution. There are 3 objects: Account, Infusion__c, Patient__c. Infusion__c is a child of Accounts, and Infusion__c has a ...
0
votes
2answers
40 views

Manual Rollup (Sum) behaving differently than Reports and AggregateResult Sum

I'm not sure what is going on here. I'm wrote/summed up some anonymous apex to demonstrate some the discrepancies I'm seeing. Sometimes the values are accurate, sometimes close, sometimes just way off....
0
votes
1answer
223 views

Collect text fields in Aggregate Result Query

I have an aggregate result to process OpportunityLineItems by custom field PackageId - using min, max, avg etc for most fields works fine. However, for a text field I want to collect all the values ...
8
votes
2answers
405 views

How to Deserialize AggregateResults?

Is it possible to deserialize AggregateResults? If not, why? When I try it the regular way, all my aggregate results are empty: List<AggregateResult> arList = [SELECT Name FROM Account GROUP ...
0
votes
1answer
233 views

Getting Error: “Illegal assignment from List<AggregateResult> to List<ReportsColumnMap__c>”

Here is my code ` global with sharing class ReportsListController { public String dcarr { get; set; } public static ReportsColumnMap__c repcols { get; set; } public ReportsListController() {...
0
votes
1answer
38 views

Want to be able to validate the Child field to not exceed the Parent field (multiple child records and multiple fields)

I'm trying to write a trigger that would basically identify the value of a field on a parent Case. Then, make sure that the value that is entered in the child field (on ALL child cases together) is ...
1
vote
1answer
506 views

Passed Aggregate Results and assigning to values

I have aggregate results I am passing to a method in a class. Here is my Results query: AggregateResult[] groupedOLIs = [ select SUM(TotalPrice)TotalPriceSum, MIN(StartDate__c)StartMin,...
1
vote
1answer
81 views

Need help Writing tests for loop targeting sum amount

I need to write a test case for this code currently I have 63% coverage. I am new at this and am having trouble understanding how to target my code. As you can see in the image below I am failing with ...
1
vote
1answer
76 views

Can anything be done to improve the speed of a Salesforce Communities pages

I have couple community pages which takes about 10-15 seconds to load data. There are few aggregates quires running behind the pages to fetch data. Other pages is fine as they have only one query on ...
1
vote
1answer
272 views

AggregateResult looping over empty query?

I noticed weird behavior with for-loops when used with AggregateResult SOQL. Consider the following code (executed in the After Delete trigger context on the Order_Invoice_Item__c custom object): ...
2
votes
1answer
548 views

Returning aggregate value on lightning component

I am trying to create a lightning component to display a single number which is the sum or count of a power of 1 field. Found solutions to display a list of aggregate but not an unique number. Below ...
2
votes
2answers
510 views

What is more effecient , using SOQL AVG() or to query all records and calculate their average

Is it efficient to calculate AVG using aggregate function, using a group by clause. Like: (Select Designation__c,AVG(Salary) from Employee__c GROUP BY Designation__c) Or is it efficient to fetch all ...
2
votes
1answer
764 views

get MIN date with Id from aggregate result query

the below query works but it does'nt what I'm expecting and the problem with the below query is that it gives me all the record where as; what I want is to get the minimum dob with Id. here is my ...
0
votes
1answer
164 views

Help with Test Coverage for aggregate function query

Hoping someone will be able to help me. I have come most of the way in trying to implement some code, but I have hit a road block. I am sitting right now at 66% code coverage, and I want to understand ...
8
votes
2answers
368 views

For Loop by SOQL (hidden feature?) [duplicate]

After intensively using SOQL in For Loop I have found some interesting behavior which I neither can explain nor understand. Official SF documentation also does not have any notes regarding this. For ...
0
votes
1answer
710 views

Returning Key-value pair from a Map into a lightning component

I have a aggregate list which is returned only summary of 6 values. I want them to be displayed as percentage vales in a tables with 2 columns. First column is for the description of the summary value ...
1
vote
1answer
268 views

Problem extracting values from AggregateResult, results in NULL

I admit that I haven't done too much with the AggregateResult object but I can't figure out how to successfully extract the values to add to a Set. Here's my code: public List<AggregateResult> ...
6
votes
1answer
571 views

Is there a way I can mock an AggregateResult?

I'm trying to write most of my tests without hitting salesforce database. For that I'm implementing some simple mock class where I just return some SOQL queries when needed. The problem I'm facing now ...
0
votes
2answers
2k views

Get Record Id of Max(Date) record from Aggregate Result SOQL query (most recent campaign membership by campaign enddate)

First time using aggregate functions in SOQL in Apex, and looking for a little bit of help. I'm trying to pull the "last" campaign membership off a contact in apex so that I can update their status, ...
1
vote
2answers
2k views

How to convert Date Time field value to Date value in SOQL query

I am trying to query an aggregated result but since one of my field(HLA_Expiration_Date__c ) is formula field(Date) its returning Date Time. is there any way to convert the value of this field into ...
0
votes
1answer
125 views

Assign queried Decimal to a Decimal variable

question - want to use a number field called Rebate_Amount__c on object called Rebate_schedule__c (child to Opportunity) to cut a rebate on the Amount__c field on a Revenue_schedule_Summary_Amount__c ...