12 Replies Latest reply: Feb 19, 2018 9:48 AM by Diana Socha RSS

    Generate counter by groups

    Diana Socha

      Hi People!

       

      Please Help me, I try to make a consecutive number like this:

       

      COD               NIT             Consecutive

      00000          123456          000001

      00000          123456          000001

      00000          123456          000001

      00000          123456          000001

      00000          234567          000002

      00000          234567          000002

      00000          234567          000002

      00000          234567          000002

      00009          345678          000003

      00009          345678          000003

      00010          345678          000003

      00010          345678          000003

      00011          345678          000003


      I need to assign the consecutive number and this depends on NIT and COD value.

        • Re: Generate counter by groups
          Sunny Talwar

          It seems to be only dependent on NIT... May be this

           

          Num(AutoNumber(NIT), '000000') as Consecutive

            • Re: Generate counter by groups
              Diana Socha

              My calculation conditions changes. Now I need to make this:

               

              COD            NIT&COD1     CONSEC

               

              00009          123450001     000001

              00009          123450001     000002

              00009          123450001     000003

              00009          123450002     000001

              00009          123450002     000002   

              00009          123450003     000001   

              00009          123450004     000002

              00010          456780001     000001

              00010          456780002     000001  

              00010          456780002     000002

               

              How I can enumerate in this form?

                • Re: Generate counter by groups
                  Sunny Talwar

                  This

                   

                  Num(AutoNumber(RowNo(), COD&NIT&COD1), '000000') as CONSEC

                    • Re: Generate counter by groups
                      Diana Socha

                                              NIT&COD1               CONSEC

                      50009692900000000001
                      50009692900000000001
                      50009692900000000001
                      50009692900000100002
                      50009692900000100002
                      50009692900000100002
                      50009692900000100002
                      50009692900000100002
                      50009692900000100002
                      50009692900000100002
                      50009692900000100002
                      50009692900000200003
                      50009692900000200003
                      50009692900000200003
                      50009692900000200003
                      50009692900000200003
                      50009692900000200003
                      50009692900000200003
                      50009692900000900004
                      50009692900000900004
                      50009692900000900004
                      50009692900000900004
                      50009692900000900004
                      50009692900000900004
                      50009692900000900004
                      50009692900000900004
                      50009692900000900004
                      50012295900095500001
                      50012295900095500001
                      50012295900095500001
                      50012295900095500001
                      50012295900095500001
                      50012295900095500001
                      50012915700095900001
                      50012915700095900001
                      50012915700095900001
                      50012915700095900001
                      50012915700095900001
                      50012915700095900001
                      50012915700095900001
                      50012915700095900001
                      50012915700096000002
                      50012915700096000002
                      50012915700096000002
                      50012915700096000002
                      50012915700096000002
                      50012915700096000002
                      50012915700096000002
                      50015025000001200001
                      50015025000001200001
                      50015025000001200001
                      50015025000001200001
                      50015025000001200001

                       

                       

                       

                      And, have you any idea for this format?

                        • Re: Generate counter by groups
                          Sunny Talwar

                          Not sure I understand the question? Can you elaborate?

                            • Re: Generate counter by groups
                              Diana Socha

                              In this case I need a consecutive code that correspond with NIT&COD1 but when NIT&COD1 changue, the consecutive start in 00001 again. This data is in groups.

                               

                              NIT( first 9 characters); COD1(next 6 characters);  COD1 define a new group on master group defined by NIT. When NIT changues The consecutive should start in 00001 again.

                               

                              NIT&COD1                  CONSEC

                              50009692900000000001
                              50009692900000000001
                              50009692900000000001
                              50009692900000100002
                              50009692900000100002
                              50009692900000100002
                              50009692900000200003
                              50009692900000200003
                              50009692900000200003
                              50009692900000900004
                              50009692900000900004
                              50009692900000900004
                              50012295900095500001
                              50012295900095500001
                              50012295900095500001
                              50012915700095900001
                              50012915700095900001
                              50012915700095900001
                              50012915700096000002
                              50012915700096000002
                              50012915700096000002
                              50015025000001200001
                              50015025000001200001
                              50015025000001200001
                                • Re: Generate counter by groups
                                  Sunny Talwar

                                  May be like this

                                   

                                  AutoNumber(NIT&COD1, Left(NIT&COD1, 7)) as CONSEC

                                    • Re: Generate counter by groups
                                      Sunny Talwar

                                      Check this script

                                       

                                      Table:

                                      LOAD RowNo() as RowNum,

                                      *,

                                      Num(AutoNumber([NIT&COD1], Left([NIT&COD1], 7)), '000000') as CONSEC;

                                      LOAD * INLINE [

                                          NIT&COD1

                                          500096929000000

                                          500096929000000

                                          500096929000000

                                          500096929000001

                                          500096929000001

                                          500096929000001

                                          500096929000002

                                          500096929000002

                                          500096929000002

                                          500096929000009

                                          500096929000009

                                          500096929000009

                                          500122959000955

                                          500122959000955

                                          500122959000955

                                          500129157000959

                                          500129157000959

                                          500129157000959

                                          500129157000960

                                          500129157000960

                                          500129157000960

                                          500150250000012

                                          500150250000012

                                          500150250000012

                                      ];

                                       

                                      Capture.PNG

                        • Re: Generate counter by groups
                          Jahanzeb Hashmi

                          I would say

                          Hash128(COD,NIT) as Consecutive,

                          • Re: Generate counter by groups
                            omar bensalem

                            as I see it's only based on NIT no?

                            and do u want it on the script or in a table? without altering the script?