Announcements
cancel
Showing results for
Did you mean:
Creator

## Unique value counter at the backend

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

ABC
1111231
1111242
1111253
1111264
1111275
1111286
1111297
2222121
2222132
2222143
2222154
3333131
3333142

Any help will be greatly appreciated.

Regards,

1 Solution

Accepted Solutions
Creator
Author

Hi Jonathan,

Instead of Peek(C), Peek(C)+1 has worked.

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.

3 Replies
Partner - Champion III

Like this

A,

B,

If(A = Previous(A) And B <> Previous(B), Peek(C) +1, 1) as C

FROM ...

ORDER By A, B;

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Creator
Author

the field C isn't there in the data, we need to create C with the given condition.

Creator
Author

Hi Jonathan,

Instead of Peek(C), Peek(C)+1 has worked.

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.