Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
siddharthsoam
Contributor 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
vijetasharma
Valued Contributor

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

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
Honored Contributor II

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

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
Contributor II

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

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
Honored Contributor II

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

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
Contributor II

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

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.