Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
````
Dummy:
LOAD * INLINE [
Customer, Sales, Flag
A, 100, 2
A, 150, 2
A, 300, 0
B, 50, 3
B, 100, 2
B, 30, 1
];
```
Hi, I want to group this dummy data by customer, but with the condition to sum just register where each customer Flag has is top value.
So for customer A registers must sum only where Flag = 2 and for customer B registers where Flag = 3.
is there any way to do it dynamically?
```
// Dummy table solution
// A, 250, 2
// B, 50, 3
```
@adecora try below
Data:
LOAD * INLINE [
Customer, Sales, Flag
A, 100, 2
A, 150, 2
A, 300, 0
B, 50, 3
B, 100, 2
B, 30, 1
];
Inner Join(Data)
Load Customer,
max(Flag) as Flag
Resident Data
Group by Customer;
Final:
load Customer,
sum(Sales) as Sales
Resident Data
Group by Customer;
Drop Table Data;
@adecora try below
Data:
LOAD * INLINE [
Customer, Sales, Flag
A, 100, 2
A, 150, 2
A, 300, 0
B, 50, 3
B, 100, 2
B, 30, 1
];
Inner Join(Data)
Load Customer,
max(Flag) as Flag
Resident Data
Group by Customer;
Final:
load Customer,
sum(Sales) as Sales
Resident Data
Group by Customer;
Drop Table Data;
Thanks, this was exactly what i was looking for.