Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

variable in formula

hi all,

i am trying to set the value of a variable in a formula, but unfortunately it does not work.

i have a diagram where i present a green, yellow or red icon depending on the result of if statements.

at the same time i would like to count the number of greens, yellows and reds and save the count in variables vGreen, vYellow and vRed.

is this somehow possible ?

Thanks a lot for any hints and ideas.

regards,

K

1 Solution

Accepted Solutions
its_anandrjs
Champion III
Champion III

Hi,

Create variables by clicking Ctrl+Alt+V and write some thing like

Without set analysis

vGreen =  Count( If( TestClass = 'Exam' ,Success) >= PassRequired, Success )

vYellow = Count( If( TestClass = 'Exam' ,Success) > 0, Success )

vRed =   Count(  If( TestClass = 'Exam' ,Success) = 0, Success  )

Or i dont know what is your condition but you have to do like this or use set analysis also

And use this variable value in text box to display value like

=$(vGreen)

Rgds

Anand

View solution in original post

5 Replies
its_anandrjs
Champion III
Champion III

Hi,

Use the same condition like you use in showing greens, yellows and reds use individuals color value condition in  vGreen, vYellow and vRed variables.

Rgds

Anand

SunilChauhan
Champion II
Champion II

see the attached file

hope this heelp

Sunil Chauhan
Not applicable
Author

@ Anand: thanks for the prompt reply.

just to understand correctly:

- these are my conditions to show the icons:

     //green if all

  =                              if ( count ( {$<TestClass={Exam}>} Success) >= PassRequired,                              'qmem://<bundled>/BuiltIn/led_g.png',

                              //yellow if at least something passed

                              if ( count ( {$<TestClass={Exam}>} Success) > 0, 'qmem://<bundled>/BuiltIn/led_y.png',

                              //red if nothing

                              if ( count ( {$<TestClass={Exam}>} Success) = 0 , 'qmem://<bundled>/BuiltIn/led_r.png',

                              )

                              )

                              )

- and for the variables you suggest to do it this way ?

//green if all

  = if ( count ( {$<TestClass={Exam}>} Success) >= PassRequired, vGreen +1,

  //yellow if at least something passed

  if ( count ( {$<TestClass={Exam}>} Success) > 0, vYellow +1,

  //red if nothing

  if ( count ( {$<TestClass={Exam}>} Success) = 0 , vRed +1,

  )

  )

  )

... if this is the case: i tried it this way (selected to not show the formula in the diagram) and showed the variables in 3 different text boxes. (in initialized the variables with 0 ( vGreen = 0; etc)) and they never change their value. so my text boxes always show 0....

what am i doing wrong ?

@Sunil Chauchand: No, this is not what i am looking for. I actually want to count the appearances of grens, reds, yellows and store this value in variables...

thanks a lot!

its_anandrjs
Champion III
Champion III

Hi,

Create variables by clicking Ctrl+Alt+V and write some thing like

Without set analysis

vGreen =  Count( If( TestClass = 'Exam' ,Success) >= PassRequired, Success )

vYellow = Count( If( TestClass = 'Exam' ,Success) > 0, Success )

vRed =   Count(  If( TestClass = 'Exam' ,Success) = 0, Success  )

Or i dont know what is your condition but you have to do like this or use set analysis also

And use this variable value in text box to display value like

=$(vGreen)

Rgds

Anand

Not applicable
Author

Thanks! This did the job!

How would you do this using SetAnalysis ?