Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If condition not to be hardcoded.

Hi,

I was just wondering if its possible that condition in a QVW is not hardcoded.

My requirement is I am using a guage chart where when certain condition are met it points the needle to the set reason . but the user wants the values on which condition are dependent can change with time .

Is it possible that we can change the condition value without rewriting teh condition and setting the value.

Presently i have made the attached guage chart wher ethe condition set is hard coded. i want them to be variable.

Hope i have made it lil understandable.

Plz if anybody canhelp on this

1 Solution

Accepted Solutions
biester
Specialist
Specialist

Hi,

thanks for your matrix, it's very helpful and enables us to have a look at it and think it over. Another question: WHAT exactly in this matrix should be variable? The X1 and X2 values (or better conditions) of the whole matrix?

Rgds,
Joachim

View solution in original post

7 Replies
biester
Specialist
Specialist

Hi,

you can put the whole condition into a variable, e.g. Condition and use

$(#Condition)

in the Expression. I tried to make this clear and modified your qvw - see enclosed.

But note: you have a multiply nested if statement. Let alone that this usually is a bad practice in almost every programming language, it also costs a lot of performance. Of course sometimes "if" is necessary, but I would try to avoid this construct (by the way I didn't even get the meaning of the statement). Nevertheless I hope it helped.

Rgds,
Joachim

Not applicable
Author

I do understand that nexted looping is nota agood Practice in any programming languag .. but i a have a set of condition

see below.:

X1

X2

Indicator

>= 90%

>= 90%

Green

>= 90%

>=75%,< 90%

Amber

>= 90%

< 75%

Red

>=75%,< 90%

>= 90%

Amber

>=75%,< 90%

>=75%,< 90%

Amber

>=75%,< 90%

< 75%

Red

< 75%

>= 90%

Amber

< 75%

>=75%,< 90%

Red

< 75%

< 75%

Red



To Need to put the in gauge chart .. Is there any way to get it done in a way that doesn't hamper the performance nd don't have so many nested if

biester
Specialist
Specialist

Hi,

thanks for your matrix, it's very helpful and enables us to have a look at it and think it over. Another question: WHAT exactly in this matrix should be variable? The X1 and X2 values (or better conditions) of the whole matrix?

Rgds,
Joachim

biester
Specialist
Specialist

Hi,

I modified your qvw a little, introducing three variables: GreenCondition, RedCondition and AmberCondition. You can type GreenCondition and RedCondition in an inputbox as a boolean expression. I preset these values according to your schema:

RedCondition: one of the values is < 75 %
GreenCondition: both of the values are >= 90 %.
AmberCondition must then be neither RedCondition nor GreenCondition, boolean !(RedCondition Or GreenCondition). I predefined this variable also accordingly.

Only one of the three conditions can be true (-1); the others are false (0). I calculate the dashboard value:

GreenCondition*-95 + AmberConditon*-82 * RedCondition*-35,

so the value is either 95 or 82 or 35 (you have to use the correct syntax, num($(#GreenCondition))*-95 ..... of course, but you see it in the example).

Perhaps this is helpful to you,

Rgds,
Joachim

Not applicable
Author

Thanks alot Joachim Smile

In this the chart the input values are a1 and a2.. and the matrix provided shows the condition .

In my case the values in this matrix can be changed at any Point of business requirement . so i need that these values doesn't remain hardcoded and can be changed at any Point of requirement .

And in the chart provided by you . I did understand that it shows up the value of green , red and amber in the text box .. and for the variable to change up for condition.. we just need to change the condition value in the input box. Please correct me if i have misinterpreted.

biester
Specialist
Specialist

Hi,

yes, you can alter the value of GreenCondition and RedCondition in the inputbox (of course you can also alter the variable without using an inputbox, I just used it for demonstration purposes). The text boxes is also just for demonstration and to check whether the expressions are evaluated correctly. In fact, you can drop the text boxes and the input box, only the variables and the expression in the chart are essential).

Of course you must be sure that the boolean expressions are logically plausible, i.e. that e. g. GreenCondition and RedCondition are not identical. But on the whole you are flexible with this solution, and it's better to maintain than a thousand "if"s, I would say ;-).

Hope that it helps,
Rgds,
Joachim

Not applicable
Author

Thanks alot Joachim... Smile

Yes the soln really helped me and even get rid of those loads of 'If ' 🙂