Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression inside a set expression

I have a set expression which returns the number of employees fulfilling the below criteria

=Count (Distinct {$<Rundate={$(vRundate)}, Maxdate={'<$(vMaxdate)'} >} EmpID)

where vRundate is 201401 and vMaxdate is 201408

Now my query is that i want to put this in a chart where my dimension will be Month and vRundate and vMaxdate will change based on Month.

Right now its a variable and can store only one value at a time but since my chart will have Month as dimension and it will have values from Jan-Aug so my variable value should change for every month as highlighted in the table below.

MonthvRundatevMaxdate
Jan201401201402
Feb201402201403
Mar201403201404
Apr201404201405
May201405201406
Jun201406201407
Jul201407201408

How can i do this ? Can we write expression inside a set expression and pass values of Rundate and Maxdate like Rundate= Max(Month)+1 or simething like this ?

Thanks a lot in advance,

Sumit

13 Replies
anbu1984
Master III
Master III

Yes you can write an expression inside set like below


=Count (Distinct {$<Rundate={$(= Max(Month)+1)}, Maxdate={'<$(vMaxdate)'} >} EmpID)

Not applicable
Author

Doesn't work. It doesn't take Max as a function

anbu1984
Master III
Master III

Missed bracket in the expression

=Count (Distinct {$<Rundate={$(= Max(Month)+1))}, Maxdate={'<$(vMaxdate)'} >} EmpID)

Not applicable
Author

Bracket was already there. However giving extra bracket would give an error.

lironbaram
Partner - Master III
Partner - Master III

hi

in this case you can't use set analysis

as set analysis is like making a selection in the model , it will return the same results in all month

you can try something like assuming you have a date field

Count (if(Rundate=num(year(monthstart(Date))&num(month(monthstart(Date)))) and

Maxdate <num(year(monthstart(Date))&num(month(monthstart(Date)))+1), EmpID)

Not applicable
Author

You need to specify your variable names with generalised month variable without using the '=' sign in the expression for the variablr i.e. vRundate and vMaxdate.

Hope this helps

anbu1984
Master III
Master III

You are right. Can you post sample qvw.

Not applicable
Author

Was that reply for me?

anbu1984
Master III
Master III

No Gaurav