Forum Discussion
Help - Query hasn't grouped properly
- 2 years ago
This happened because you included the 'AllocatedQuantity' in your group by. It looks like all of the other rows had a quantity of 800 so it grouped all of those together and grouped the one with 700 by itself.
To fix this, just go into the step where you grouped the columns and remove the 'Allocated Quantity' from the grouping!
You want to group on the fields that you're not going to aggregate.
For example:
| Category | Product | Sales |
| A | Toy | 10 |
| A | Shirt | 20 |
| A | Shirt | 15 |
If I want to find out how much I've sold of each Category and Product I'd group those fields and aggregate (sum) the Sales column which would give me this.
| Category | Product | Sales |
| A | Toy | 10 |
| A | Shirt | 35 |
The grouping finds distinct combinations to perform your aggregation. That's why you had the issue, because you were including the Sales column in your grouping (which in this example, would be the exact same as the first table).
Hi Syk ,
Thank you for the explanation, it makes sense as to why it wasnt working now.
I appreciate your help 🙂