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

IF condition in the script

How can I use If condition in the script when I have the situation below?

I need to show the Qty fild only if I have the 'Y'  in the Trans field .

The problem is the Trans field is from the Order table and the Qty fild is from the OrderDetail table.

Order:
LOAD 
Pedido      as Order,
DtPedido as OrderDate,
CGC as Customer,
Represen as Rep,
Trans
FROM (qvd);

OrderDetail:
LOAD
Pedido      as Order,
Modelo      as Produc

  Qty
// if (Trans = 'Y', Qty) as Order_Qty
FROM (qvd);

Best Regards,

Rodrigo

1 Solution

Accepted Solutions
robertomontanar
Partner - Contributor III
Partner - Contributor III

There are more than one solution; I like solutions:  a)-easy to understand, b)-fast in reload.

This is my suggestion:

Order:
LOAD 
Pedido      as Order,
DtPedido as OrderDate,
CGC as Customer,
Represen as Rep,
Trans

,if (Trans = 'Y', Pedido)  as TransOrder  // add a new field with "Trans" Orders only

FROM (qvd);

OrderDetail:
LOAD
Pedido as Order,
Modelo as Produc

,if(exists(TransOrder,Pedido),Qty) as Order_Qty  // fill the Qty for "Trans" Orders

FROM (qvd);

You like ?

Roberto

View solution in original post

2 Replies
robertomontanar
Partner - Contributor III
Partner - Contributor III

There are more than one solution; I like solutions:  a)-easy to understand, b)-fast in reload.

This is my suggestion:

Order:
LOAD 
Pedido      as Order,
DtPedido as OrderDate,
CGC as Customer,
Represen as Rep,
Trans

,if (Trans = 'Y', Pedido)  as TransOrder  // add a new field with "Trans" Orders only

FROM (qvd);

OrderDetail:
LOAD
Pedido as Order,
Modelo as Produc

,if(exists(TransOrder,Pedido),Qty) as Order_Qty  // fill the Qty for "Trans" Orders

FROM (qvd);

You like ?

Roberto

Not applicable
Author

Thanks for you reply Roberto. I liked very much!