Skip to main content
Announcements
Qlik Acquires Upsolver to Advance Iceberg Solutions: READ MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
sushantk19
Creator
Creator

How to pass multiple values to a context

Hi,

 

Is there a way we can define & pass multiple values to a context? e.g

 

context.brand_id=(1,2). how to define this in contexts tab? context.brand_id= "1|2"?

Labels (2)
26 Replies
Anonymous
Not applicable

simple solution: prepare your context parameter file x;1 x;2 then pass this file as normal tfileinputdelimited > tflowtoiterate> Iterate link to your entire job (or use that job as tRunJob) when you run your mother job , the value of x will be passed one by one for every iteration. Possible to do the same thing in different ways also. Feel free to give kudos to solutions, if it helps !
sushantk19
Creator
Creator
Author

@snayak : i know its simple Smiley Wink. since I am new to talend, i am not getting it correct. some small mistake is happening somewhere. can you please point out that to me?Please find the context file attached along with other screenshots such as job design, error message and tfileinputdelimited datatype defination.

 

can you please point out the error to me?

sushantk19
Creator
Creator
Author

@snayak : i know its simple Smiley Wink. since I am new to talend, i am not getting it correct. some small mistake is happening somewhere. can you please point out that to me?Please find the context file attached along with other screenshots such as job design, error message and tfileinputdelimited datatype defination.

 

can you please point out the error to me?


contexts_productcat.txt
tcontext_error1.png
tcontext_error2.png
tcontext_error3.png
manodwhb
Champion II
Champion II

@sushantk19 , what are you doing in tMap2,can you share screenshot of tMap2? the error you are getting is compilation error not run time error. you have not configured correctly for one or more columns.When comparing strings you should use equals instead of == . One more thing that let have below way. not needed context. .

prodcat_mia1;6

prodcat_mia1;7

manodwhb
Champion II
Champion II

@sushantk19 , what are you doing in tMap2,can you share screenshot of tMap2? the error you are getting is compilation error not run time error. you have not configured correctly for one or more columns.When comparing strings you should use equals instead of == . One more thing that let have below way. not needed context. .

prodcat_mia1;6

prodcat_mia1;7

sushantk19
Creator
Creator
Author

@manodwhb : please find attached the screenshot for tmap2. Based on product categories and date interval, we are calculating the VAT rates. For product category 7 and 8, the calculation is same. Hence i want to pass both these values in a single context.

 

When i run the job with above suggestions , i get the below error:

 

Couldn't parse value for column 'value' in 'row13', value is 'prodcat_mia1'. Details: java.lang.NumberFormatException: For input string: "prodcat_mia1"
Couldn't parse value for column 'value' in 'row13', value is 'prodcat_mia1'. Details: java.lang.NumberFormatException: For input string: "prodcat_mia1".

 

i have defined a context with name as prodcat_mia1 in "contexts" tab.

also the tmap logic is as below:

 

(Load_data.brand_id==context.brand_id_mia && Load_data.country_id==context.country_id && Var.var1 =="Y" && Load_data.productcategory_id ==context.prodcat_mia1)?context.VAT_Reduced_1:context.VAT_Normal_2

 

the highlighted BOLD part is where i have to pass both the values. the same logic should work for prod category 7 and 8.

sushantk19
Creator
Creator
Author

@manodwhb : please find attached the screenshot for tmap2. Based on product categories and date interval, we are calculating the VAT rates. For product category 7 and 8, the calculation is same. Hence i want to pass both these values in a single context.

 

When i run the job with above suggestions , i get the below error:

 

Couldn't parse value for column 'value' in 'row13', value is 'prodcat_mia1'. Details: java.lang.NumberFormatException: For input string: "prodcat_mia1"
Couldn't parse value for column 'value' in 'row13', value is 'prodcat_mia1'. Details: java.lang.NumberFormatException: For input string: "prodcat_mia1".

 

i have defined a context with name as prodcat_mia1 in "contexts" tab.

also the tmap logic is as below:

 

(Load_data.brand_id==context.brand_id_mia && Load_data.country_id==context.country_id && Var.var1 =="Y" && Load_data.productcategory_id ==context.prodcat_mia1)?context.VAT_Reduced_1:context.VAT_Normal_2

 

the highlighted BOLD part is where i have to pass both the values. the same logic should work for prod category 7 and 8.


tmap_logic_contexts.png
sushantk19
Creator
Creator
Author

@manodwhb : also check if the parameter file defination is correct. parameter file is also uploaded.

sushantk19
Creator
Creator
Author

@manodwhb : also check if the parameter file defination is correct. parameter file is also uploaded.


contexts_productcat.txt
tinputfile_defination.png
manodwhb
Champion II
Champion II

@sushantk19 , you need to use the below way. since productcategory_id is a string data type.

 

Load_data.productcategory_id.equas(context.prodcat_mia1)