Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have Columns A and B (sorted). I wanted to have column C calculated and added to the table (at the backend) by the below logic:
- The value of C will start with 1 and will continue to increment until values in A are same, and the values in B are changing.
- After the value in A is changed, the value in C will again start with 1 and keep on increasing till the values in B are changing
A | B | C |
---|---|---|
111 | 123 | 1 |
111 | 124 | 2 |
111 | 125 | 3 |
111 | 126 | 4 |
111 | 127 | 5 |
111 | 128 | 6 |
111 | 129 | 7 |
222 | 212 | 1 |
222 | 213 | 2 |
222 | 214 | 3 |
222 | 215 | 4 |
333 | 313 | 1 |
333 | 314 | 2 |
Any help will be greatly appreciated.
Regards,
Bhaskar
Hi Jonathan,
Instead of Peek(C), Peek(C)+1 has worked.
LOAD
A,
B,
If(A = Previous(A) And B <> Previous(B), Peek(C) + 1, 1) as C
FROM ...
ORDER By A, B;
Thanks for the help.
Bhaskar
Like this
LOAD
A,
B,
If(A = Previous(A) And B <> Previous(B), Peek(C) +1, 1) as C
FROM ...
ORDER By A, B;
the field C isn't there in the data, we need to create C with the given condition.
Hi Jonathan,
Instead of Peek(C), Peek(C)+1 has worked.
LOAD
A,
B,
If(A = Previous(A) And B <> Previous(B), Peek(C) + 1, 1) as C
FROM ...
ORDER By A, B;
Thanks for the help.
Bhaskar