0

Why do I get this ERROR as :MALFORMED Query in Developer console?

I'm trying to use :Group By Roll or Group By CUbe to get the subtotals and grand totals.

When I tried this Query:

SELECT  id,gmod__Quantity__c,  gmod__Amount__c,GROUPING(gmod__Quantity__c) grpQty, GROUPING(gmod__Amount__c) grpAmt ,COUNT(id) oppfc from gmod__Opportunity_Forecast__c GROUP BY CUBE(gmod__Quantity__c, gmod__Amount__c) ORDER BY GROUPING(gmod__Quantity__c), GROUPING(gmod__Amount__c)

Error as :

MALFORMED QUERY [object Object]: gmod__Opportunity_Forecast__c GROUP BY CUBE(gmod__Quantity__c, gmod__Amount__c) ^ ERROR at Row:1:Column:183 field 'gmod__Quantity__c' can not be grouped in a query call

Similarly I just tried using Grouping By One Rollup Field

SELECT  gmod__price__c,COUNT(Name) cnt
    FROM gmod__Opportunity_Forecast__c
    GROUP BY ROLLUP( gmod__price__c) 

Grouping By Two Rollup Field

SELECT  gmod__price__c,gmod__Amount__c ,COUNT(Name) cnt
FROM gmod__Opportunity_Forecast__c
GROUP BY ROLLUP( gmod__price__c,gmod__Amount__c)

It does not give any o/p result.

2
  • Unfortunately, you can not use all fields to group by. A field has to be groupable. There seems to be some mystery about when a field is groupable and when it isn't, also see this question: salesforce.stackexchange.com/questions/5818/… Commented Feb 9, 2015 at 13:20
  • @Lex:Quantity field is a number data type,price is a currency data type and Amount is formula field currency data type.so it not possible for the currency or number data type to be grouped
    – nikkey
    Commented Feb 9, 2015 at 18:21

0

You must log in to answer this question.

Browse other questions tagged .