Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
santhosh_k_n
Creator II
Creator II

Show condition for expression

Hi All,

Please let me know which is most suggestible in Chart expression tab,

1. having two similar expression with different show conditions

                              or

2. using one expression with a if clause for same conditions.

for example:

I want to display a report based on the type of product selected in the filter (Type of filter ={Stationary,Non-stationary})

1. two expression sum({Type={stationary} }sales) and sum({Type={Non-stationary} }sales) with show condition enabled for two exp's

2. if(Type=Stationary,sum({Type={stationary} }sales),sum({Type={Non-stationary} }sales))

Regards,

Santhosh N

9 Replies
Not applicable

Hi Santhosh,

I would recommend two separate expression with the required show conditions rather than a single with IF statement.

From a performance point of view and easy of maintenance I would think it better

Anonymous
Not applicable

Option 1 for sure. 1 chart, 2 expressions, show / hide each expression based on your filter. Much easier to work out how it works later and maintain / add to if needed.

PradeepReddy
Specialist II
Specialist II

first option is recommended... as it takes less time to evaluate condition and provides the results in short time when compared to the second option.

santhosh_k_n
Creator II
Creator II
Author

Thanks Joe/Richard/Pradeep for your response.

But how to handle this with more than two conditions and more than one exp,

Say for eg: Type ={Stationary,Non-sationary} and Region_Type={Local,National,International}

exps like = Sum(Sales), Sum(revenue) etc..

PradeepReddy
Specialist II
Specialist II

can u elaborate under what conditions you are showing sum(Sales)?

santhosh_k_n
Creator II
Creator II
Author

Hi Pradeep, Please find few conditions

1. Sum({<Type=Stationary,Region_Type=local>}sales)

2.  Sum({<Type=Stationary,Region_Type=National>}sales)

3.  Sum({<Type=Stationary,Region_Type=International>}sales)

and so on.....

sasikanth
Master
Master

Hi,

Let me know one thing here ,

if you are selecting a value in listbox and

a chart is there with dim YEAR and Exps are Sum(sales) and Sum( revenue),

based on selections the chart will show the Sales and revenue , here

conditional enabling is not required .

Thanks

Sasi

santhosh_k_n
Creator II
Creator II
Author

Hi Sasikanth,

What you have said is right and i accept if they are some fileds in the data model, say if the filters are some flag fields added and having no relation ship to the data model created, in such scenario which option should do you suggest

sasikanth
Master
Master

HI ,

if we have CAL YEAR and FIN YEAR  then if we want to enable based on the selection then go for

Script level flags like following

LOAD * Inline [

Calendar, CAL_FLAG,FIN_FLAG

CAL YEAR,   1,  0

FIN YEAR ,  0,  1

];

Then use the flag values in the expression like

sum({<YEAR={'CAL YEAR'}>} sales)*CAL_FLAG+sum({<YEAR={'FIN YEAR'}>}sales)*FIN_FLAG

i hope it will help you ,

thanks

Sasi