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

Group by not working

Hi Guys,

Any ideas why my Group By not working?

[TEST TABLE]:

LOAD

    Value,

    sum(Value_PQ) as [Total Value],

    DISTRICT

    RESIDENT temp_SALES

   GROUP BY DISTRICT;

  

   DROP TABLE temp_SALES_RXI_WS_MONTH;

1 Solution

Accepted Solutions
sunny_talwar

Either add Value in your Group By Statement or remove it from the LOAD

1)

[TEST TABLE]:

LOAD

    Value,

    sum(Value_PQ) as [Total Value],

    DISTRICT

    RESIDENT temp_SALES

   GROUP BY DISTRICT, Value;

 

   DROP TABLE temp_SALES_RXI_WS_MONTH;

2)

[TEST TABLE]:

LOAD

    sum(Value_PQ) as [Total Value],

    DISTRICT

    RESIDENT temp_SALES

   GROUP BY DISTRICT;

 

   DROP TABLE temp_SALES_RXI_WS_MONTH;

View solution in original post

8 Replies
sunny_talwar

Either add Value in your Group By Statement or remove it from the LOAD

1)

[TEST TABLE]:

LOAD

    Value,

    sum(Value_PQ) as [Total Value],

    DISTRICT

    RESIDENT temp_SALES

   GROUP BY DISTRICT, Value;

 

   DROP TABLE temp_SALES_RXI_WS_MONTH;

2)

[TEST TABLE]:

LOAD

    sum(Value_PQ) as [Total Value],

    DISTRICT

    RESIDENT temp_SALES

   GROUP BY DISTRICT;

 

   DROP TABLE temp_SALES_RXI_WS_MONTH;

marcus_sommer

You have another field Value within your load but not in the group by - either you put it into the group by or you removed it (I think the last will be what you wants).

- Marcus

Anonymous
Not applicable
Author

So each field needs to go into the group by?

reddy-s
Master II
Master II

Hi Lak,

All the fields not in the group by should be aggregated. this is the cause of the issue.

Instead try this:

[TEST TABLE]:

LOAD

    Only(Value),

    sum(Value_PQ) as [Total Value],

    DISTRICT

    RESIDENT temp_SALES

   GROUP BY DISTRICT;

 

   DROP TABLE temp_SALES_RXI_WS_MONTH;

sunny_talwar

Whatever isn't getting aggregated needs to be within the Group By statement

maxgro
MVP
MVP

because you miss the Value field in the group by

[TEST TABLE]:

LOAD

    Value,

    sum(Value_PQ) as [Total Value],

    DISTRICT

    RESIDENT temp_SALES

  //GROUP BY DISTRICT;                                     // NO

GROUP BY Value, DISTRICT;                            // YES



or an aggr function for the field value


[TEST TABLE]:

LOAD

    // Value,                                                                // NO

     sum(Value),                                                       // YES

    sum(Value_PQ) as [Total Value],

    DISTRICT

    RESIDENT temp_SALES

GROUP BY DISTRICT;                           




like this

load

    a, b,

    sum(c),

    count(d)

resident table

where ...

group by

    a, b;

Anonymous
Not applicable
Author

Thanks that was a nice easy one.

Anonymous
Not applicable
Author

Hi

I put images on my other question as i couldn't put the file on here.  The table expression not working within a KPI.

Thanks