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: 
emilyrabbit
Creator
Creator

how to add a condition column in the loading script

HI, below is my origin data. 

there are different product in each order

in the loading script , I want to add a new column , if the product contain 'cat' ,and the order should be remark as 'cat order' . I wonder if I can use mapping load or left join. but I am not familiar with these 2 expression. Pls help me on it, thanks.

emilyrabbit_0-1748418413493.png

below is the target :

emilyrabbit_1-1748418433497.png

 

 

Labels (2)
1 Solution

Accepted Solutions
Aditya_Chitale
Specialist
Specialist

@emilyrabbit 

Are you looking for something like this ?

test:     //Load Base table
LOAD   
    "Order",
     Product
FROM [lib://TestFolder/Sales Test.xls]
(biff, embedded labels, table is Sheet1$);

left join (test)
//concat all products grouped on basis of order and 
//left join with base table
Load 
	"Order",
	concat(trim(Product),'|') as IsCat
Resident test 
group by "Order";

NoConcatenate

//use if condition to determine order type as a whole based on //order
final:   
load
	"Order",
     Product,
    if(wildmatch(IsCat,'*Cat*'),'Cat Order','not cat order') as "Order Type"
Resident test;

Drop table test;

 

Output:

Aditya_Chitale_0-1748497111346.png

 

Regards,

Aditya

View solution in original post

8 Replies
Adam_Romanowski
Partner - Creator
Partner - Creator

LOAD

[Order],

[Order line]

[Product],

if(Product='cat', 'cat order', 'not cat order') as [Order type]

from ...

 

emilyrabbit
Creator
Creator
Author

Hi , the result is not correct. C contains "cat" , but order type still show "not cat order"

emilyrabbit_0-1748480737759.png

 

emilyrabbit
Creator
Creator
Author

@MatheusC  can you also help me check it ?Thanks.

Aditya_Chitale
Specialist
Specialist

@emilyrabbit 

Maybe there are empty spaces in the column values. try using below expression:

if(wildmatch(trim(Product),'cat'), 'cat order', 'not cat order') as [Order type]

 

Regards,

Aditya

emilyrabbit
Creator
Creator
Author

Hi, for some order line , there is not "cat" ,for instance ,C2 & C2 , but for the C order , it should show "cat order" . it isn't the match expression. 

Aditya_Chitale
Specialist
Specialist

@emilyrabbit 

Are you looking for something like this ?

test:     //Load Base table
LOAD   
    "Order",
     Product
FROM [lib://TestFolder/Sales Test.xls]
(biff, embedded labels, table is Sheet1$);

left join (test)
//concat all products grouped on basis of order and 
//left join with base table
Load 
	"Order",
	concat(trim(Product),'|') as IsCat
Resident test 
group by "Order";

NoConcatenate

//use if condition to determine order type as a whole based on //order
final:   
load
	"Order",
     Product,
    if(wildmatch(IsCat,'*Cat*'),'Cat Order','not cat order') as "Order Type"
Resident test;

Drop table test;

 

Output:

Aditya_Chitale_0-1748497111346.png

 

Regards,

Aditya

MatheusC
Specialist II
Specialist II

I'm a little late.

Did you manage to solve it? It seems like @Aditya_Chitale  solution is what you're looking for, or is there something else I might be missing?

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
emilyrabbit
Creator
Creator
Author

thanks . I found the solution ,using the mapping loading .