# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Partner

## Generate counter by groups

Hi People!

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.

1 Solution

Accepted Solutions
MVP

## Re: Generate counter by groups

Check this script

Table:

*,

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

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

];

12 Replies
MVP

## Re: Generate counter by groups

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

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

Valued Contributor

## Re: Generate counter by groups

I would say

Hash128(COD,NIT) as Consecutive,

Partner

## Re: Generate counter by groups

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?

Partner

## Re: Generate counter by groups

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?

Partner

## Re: Generate counter by groups

I need to do that in the script

MVP

## Re: Generate counter by groups

This

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

Partner

## Re: Generate counter by groups

NIT&COD1               CONSEC

 500096929000000 00001 500096929000000 00001 500096929000000 00001 500096929000001 00002 500096929000001 00002 500096929000001 00002 500096929000001 00002 500096929000001 00002 500096929000001 00002 500096929000001 00002 500096929000001 00002 500096929000002 00003 500096929000002 00003 500096929000002 00003 500096929000002 00003 500096929000002 00003 500096929000002 00003 500096929000002 00003 500096929000009 00004 500096929000009 00004 500096929000009 00004 500096929000009 00004 500096929000009 00004 500096929000009 00004 500096929000009 00004 500096929000009 00004 500096929000009 00004 500122959000955 00001 500122959000955 00001 500122959000955 00001 500122959000955 00001 500122959000955 00001 500122959000955 00001 500129157000959 00001 500129157000959 00001 500129157000959 00001 500129157000959 00001 500129157000959 00001 500129157000959 00001 500129157000959 00001 500129157000959 00001 500129157000960 00002 500129157000960 00002 500129157000960 00002 500129157000960 00002 500129157000960 00002 500129157000960 00002 500129157000960 00002 500150250000012 00001 500150250000012 00001 500150250000012 00001 500150250000012 00001 500150250000012 00001

And, have you any idea for this format?

MVP

## Re: Generate counter by groups

Not sure I understand the question? Can you elaborate?

Partner

## Re: Generate counter by groups

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

 500096929000000 00001 500096929000000 00001 500096929000000 00001 500096929000001 00002 500096929000001 00002 500096929000001 00002 500096929000002 00003 500096929000002 00003 500096929000002 00003 500096929000009 00004 500096929000009 00004 500096929000009 00004 500122959000955 00001 500122959000955 00001 500122959000955 00001 500129157000959 00001 500129157000959 00001 500129157000959 00001 500129157000960 00002 500129157000960 00002 500129157000960 00002 500150250000012 00001 500150250000012 00001 500150250000012 00001