Skip to main content
Announcements
Marching toward a simplified navigation! READ ON
cancel
Showing results for 
Search instead for 
Did you mean: 
bhaskarsharma03
Creator
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,

Bhaskar

1 Solution

Accepted Solutions
bhaskarsharma03
Creator
Creator
Author

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

View solution in original post

3 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Like this

LOAD

     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
bhaskarsharma03
Creator
Creator
Author

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

bhaskarsharma03
Creator
Creator
Author

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