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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

calculo en el Script

Buen día

Agradezco su ayuda con el siguiente tema:

Necesito realizar un cálculo en el script de datos que se encuentran en la misma tabla

y necesito sumarlos : ejemplo

cod_Produc        Valor

1                 5

  2                 4

  3                 6

  4                 2

  1                 4

  1                 6      

  2                 5

  lo que he intentado hacer es algo como esto

If(Producto='1',valor + If(Producto='2',Valor)) as Valor_Prod_1_2

No me funciona

  tambien por Conjuntos

sum({<Producto={'1','2'}>}valor) as Valor_Prod_1_2

   pero tampoco me funciona,  agradezco su orientación.

2 Replies
antoniotiman
Master III
Master III

Hi,

If(Producto = '1' or Producto = '2',Valor) as Valor_Prod_1_2

Regards

Anonymous
Not applicable
Author

Hola,  no entendi  muy  bien pero si lo que quieres es unificar el  producto a uno  solo  podrias intentar esto:

TemTable:

LOAD * INLINE [

    cod_Produc, Valor

    1, 5

    2, 4

    3, 6

    4, 2

    1, 4

    1, 6

    2, 5

];

Table:

Load

if(cod_Produc=1 or cod_Produc=2 or cod_Produc=3 or  cod_Produc=4,Valor) as ValorProduc

resident TemTable;

Drop Table TemTable;


Suerte!