Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Group by Issues

I keep getting the below error when I try to group the month and year from a Salesforce.com table. Can anyone tell me what is wrong with the scripting and what do I need to do to have it run correctly?

Aggregation expressions required by GROUP BY clause


Load *,
Account__c as AccountId,
Id as OrderId,
MONTH(Billing_Date__c) AS Month,
YEAR(Billing_Date__c) AS Year,
Order__c Group BY MONTH(Billing_Date__c) ,YEAR(Billing_Date__c) ;

4 Replies
Not applicable
Author

i think the Group By function comes after the From clause.

and i didn't see any From clause

deepakk
Partner - Specialist III
Partner - Specialist III

hi,

what mOngkz suggested might be the reason or SInce you are using Load * its including all the fields from that table and in group by clause you are mentioning only one fields Billing_Date.

As per my understanding of Group by if we are mentioning any fields in Load statement then it either should be there after the group by clause or its should have aggregate function.

eg:

Load

Sum(Amount), Amount,

Sum(Price) as Price,

Product,

Category

from table group by Product, Category;

Not applicable
Author

Hi,

Please refer the link it will help u in group by and having clause.

http://community.qlik.com/forums/t/39103.aspx

Not applicable
Author

Hi,

For a group by function to work you need to things.

First:

You need an aggregation function, such as max(Date) or min(Value)  or Count(Item) etc as one of the loaded field.

Second:

You will be allowed to load only those fields, based on whom you are doing the group by.

In your case, it will be just

MONTH(Billing_Date__c) ,

YEAR(Billing_Date__c)

Hope this helps,

Regards