Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
siddharthsoam
Partner - Creator II
Partner - Creator II

How can we apply any condition to a variable in count function qliksense

Hi,

I want to use a variable in count function against certain validations.

For example

I made a variable test in set analysis with the following conditions.

if(marks>90,1,if(marks>50 and marks<=89,2,3))

I want to use this variable in count function in the expression editor,

count({$<$(temp)={1,2}>})

This way is not working for me, kindly suggest someway else

5 Replies
vijetas42
Specialist
Specialist

suppose,

you made variable temp= if(marks>90,1,if(marks>50 and marks<=89,2,3))

and now you want to use temp in count as count({$<$(temp)={1,2}>})

can you please explain what is your requirement

agigliotti
Partner - Champion
Partner - Champion

I suggest you working in the script creating a new field in your data model:

LOAD

...

if(marks>90,1,if(marks>50 and marks<=89,2,3)) as new_field


then in front end you can use a set analysis in your expression as below:


Count( {< new_field = {'1','2'} >} your_field )


Hope this helps.

siddharthsoam
Partner - Creator II
Partner - Creator II
Author

Hi Andrea,

Expression I am using is :

(Month(AddMonths (Date( Date#(HIRE_DATE,'MM/DD/YYYY'),'MMM'),1)))

My hiredate is field is the field when a particular employee is hired in 'MM/DD/YYYY' format.

I tried to make a filed out of it but am unable to do so. Though its giving me the desired result at frontend .

agigliotti
Partner - Champion
Partner - Champion

it's still not clear for me.

what's your "marks" field you mentioned above ?

could you share your script ?

and what's your expected result in the front end ?

siddharthsoam
Partner - Creator II
Partner - Creator II
Author

Hi Andrea,

The marks field I took was just for example. I am not able to run the expression (Month(AddMonths (Date( Date#(HIRE_DATE,'MM/DD/YYYY'),'MMM'),1))) where HIRE_DATE is any date field in the expression editor.