Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
carlospulgarinz
Contributor III
Contributor III

Optimize if - Pick

Hello,

how can I optimize this script?, I Have a limit of 9 rows, but my database has more of them:

fijos:

LOAD

RowNo() as id,

    identificacion,

    numero,

    fecha_telefono,

    if(identificacion=Peek(identificacion,-8),9,

    if(identificacion=Peek(identificacion,-7),8,

    if(identificacion=Peek(identificacion,-6),7,

    if(identificacion=Peek(identificacion,-5),6,

    if(identificacion=Peek(identificacion,-4),5,

    if(identificacion=Peek(identificacion,-3),4,

    if(identificacion=Peek(identificacion,-2),3,

    if(identificacion=Peek(identificacion,-1),2,1)))))))) as validacion

FROM [lib://11.14/Telefonos\PST\Fijos.qvd]

(qvd);

7 Replies
zebhashmi
Specialist
Specialist

I would say load the table first and then run this

Name:

LOAD

RowNo() as id,

    identificacion,

    numero,

    fecha_telefono

    FROM [lib://11.14/Telefonos\PST\Fijos.qvd]

(qvd);

OtherName:

Load *,

if(identificacion=Peek(identificacion,-8),9,

    if(identificacion=Peek(identificacion,-7),8,

    if(identificacion=Peek(identificacion,-6),7,

    if(identificacion=Peek(identificacion,-5),6,

    if(identificacion=Peek(identificacion,-4),5,

    if(identificacion=Peek(identificacion,-3),4,

    if(identificacion=Peek(identificacion,-2),3,

    if(identificacion=Peek(identificacion,-1),2,1)))))))) as validacion

residance Name;

Drop Table Name;

jolivares
Specialist
Specialist

Hola... Podrias colocar una tabla con los datos para ver mas claro lo que quieres y explicarte mejor.

carlospulgarinz
Contributor III
Contributor III
Author

hola buen dia,

Tengo esta tabla;

Screenshot_2.png

Con este script deseo hacer la numeración de la columna validación y que esta incie en 1 cada vez que cambia la cédula, pero el script (manualmente) me limita a hasta el numero 9, y quiero que no tenga ninguna limitación y me numere la cantidad que sea posible.

if(identificacion=Peek(identificacion,-8),9,

    if(identificacion=Peek(identificacion,-7),8,

    if(identificacion=Peek(identificacion,-6),7,

    if(identificacion=Peek(identificacion,-5),6,

    if(identificacion=Peek(identificacion,-4),5,

    if(identificacion=Peek(identificacion,-3),4,

    if(identificacion=Peek(identificacion,-2),3,

    if(identificacion=Peek(identificacion,-1),2,1)))))))) as validacion

zebhashmi
Specialist
Specialist

Are you Good!

zebhashmi
Specialist
Specialist

Try

if(identificacion=Peek(identificacion,-count(id)),count(id)+1,

jolivares
Specialist
Specialist

Ahora esto es diferente de lo que posteaste inicialmente.

Load Cedula, Telefono,

If(Cedula<>Previous(Cedula),1, Peek(Validacion)+1) as Validacion

....