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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count to check against two variables

Hi Guys,

I'm quite new to qlik and hoping someone can help as im really stuck

I was trying to count the rows which matched two variables for some reason it is not working I'm using this currently
-

=Count({$(vLeaseCoUsed)={1},STATS_Wave=$(vWaveCurr)>} $(vLeaseCoUsed))

1 Solution

Accepted Solutions
stigchel
Partner - Master
Partner - Master

I'm assuming that $(vLeaseCoUsed) is a reference to a variable field, it should be anyway, in which case I would surround it by [ ], so [$(vLeaseCoUsed)]. If the field has a space in the name it will also work. Further, depending on what is in your variable you may need to use the = operator in the dollar sign expansion [$(=vLeaseCoUsed)]

Further your STATS_Wave=$(vWaveCurr) misses the {} brackets, so STATS_Wave={$(vWaveCurr)} and again you may need STATS_Wave={$(=vWaveCurr)} and depending on the contents even STATS_Wave={'$(=vWaveCurr)'}, so with ''

And data nibbler is right you are missing the < opening right after the {

Try this

=Count({<[$(=vLeaseCoUsed)]={'1'},STATS_Wave={'$(=vWaveCurr)'}>} [$(=vLeaseCoUsed)])

View solution in original post

4 Replies
datanibbler
Champion
Champion

Hi Sarah,

you are missing an opening parenthesis < in your set_expression - right after the $, that's for one.

I'm really not sure myself about that vLeaseCoUsed - that is a variable? I have never tried to check the value of a variable in a set_expression.

stigchel
Partner - Master
Partner - Master

I'm assuming that $(vLeaseCoUsed) is a reference to a variable field, it should be anyway, in which case I would surround it by [ ], so [$(vLeaseCoUsed)]. If the field has a space in the name it will also work. Further, depending on what is in your variable you may need to use the = operator in the dollar sign expansion [$(=vLeaseCoUsed)]

Further your STATS_Wave=$(vWaveCurr) misses the {} brackets, so STATS_Wave={$(vWaveCurr)} and again you may need STATS_Wave={$(=vWaveCurr)} and depending on the contents even STATS_Wave={'$(=vWaveCurr)'}, so with ''

And data nibbler is right you are missing the < opening right after the {

Try this

=Count({<[$(=vLeaseCoUsed)]={'1'},STATS_Wave={'$(=vWaveCurr)'}>} [$(=vLeaseCoUsed)])

stigchel
Partner - Master
Partner - Master

By the way, if you want to check how this is interpreted, put the expression in a table and leave the expression label blank. That way the table header will display the expression but with the variable values evaluated, so you can check...

Not applicable
Author

Genius it works ! thanks very much