Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor

Nesting expressions which both contain commas

Hi,

I'm trying to nest expressions which both have commas.

This is a follow up of the comments and links in:  https://community.qlik.com/t5/QlikView-Creating-Analytics/variable-with-comma-parameter/td-p/1148600

The specific example I am trying to do is build two if-else expressions and use the evaluation on one if expression as the input for a second if expression.

let expression1 = if(condition_on_input, fixed_value, fixed_value);

let expression2=if(condition_on_input_1, value_from_input2, fixed_value);

and then I want to evaluate this composite $(expression2(input1, $(expression1(input2))))

as if(condition_on_input_1, if(condition_on_input2, fixed_value1,  fixed_value2),  fixed_value3);

 

However, if I try the normal way to avoid commas, the expression $(expression1(input2)) statement gets partially evaluated first, this seems to put the commas back into the expression as normal and prevents using it as an input for expression2.

I've attached a dummy dataset where I can reproduce these issues in QlikSense.

So, following the escaping rules, and replacing special characters, on that data I can get two expressions which separately work:

let eNiceYesNo_char_replace = 'if('&chr(36)&'1 = 1 or '&chr(36)&'1 = "Y" or '&chr(36)&'1 = "y"'&chr(44)&' ''Yes'' '&chr(44)&' ''No'')';

let f_partB_char_replace = 'if(match('&chr(36)&'1'&chr(44)&' ''B'' '&chr(44)&' ''C'')'&chr(44)&' '&chr(36)&'2'&chr(44)&' null)';

and in the expression editor we can see that

$(eNiceYesNo_char_replace(OUTCOME2)) expands to if(OUTCOME2=1 or OUTCOME2="Y" or OUTCOME2 = "y", 'Yes', 'No')

and $(f_partB_char_replace(MANAGEMENT_PROCESS, OUTCOME2)) expands to

if(match(MANAGEMENT_PROCESS, 'B', 'C'), OUTCOME2, null) . These both work as they should.

However, the nested expression $(f_partB_char_replace(MANAGEMENT_PROCESS, $(eNiceYesNo_char_replace(OUTCOME2))))

expands to if(match(MANAGEMENT_PROCESS, 'B', 'C'), if(OUTCOME2=1 or OUTCOME2="Y" or OUTCOME2 = "y", null) and here it was truncated at the comma.

I have also tried replacing all of the commas with ; and then running replace(expression, ';', ',') but when I replace the commas with ';' in the expression strings it breaks the loading script.

Any advice on how to make this work would be appreciated.

 

 

Labels (1)