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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
WonderMan
Contributor II
Contributor II

Using a variable in Count() for a reference line

Hi, 

I want to show a reference line and this is the expression. Somehow it's not working! It works though when I use a field name and not a variable?

Count({$<Variable1={'1'}>}distinct (field1))

Any ideas why it's not working?

 

Thks 

1 Solution

Accepted Solutions
tresB
Champion III
Champion III

In set analysis - modifiers are expected to be a field name. If your variable evaluation doesn't produce a valid field name - it wouldn't work. You can try something like:

Count(Distinct If(Variable=1, field1))   

View solution in original post

3 Replies
tresB
Champion III
Champion III

In set analysis - modifiers are expected to be a field name. If your variable evaluation doesn't produce a valid field name - it wouldn't work. You can try something like:

Count(Distinct If(Variable=1, field1))   

marcus_sommer
MVP
MVP

The set analysis expects there a native field - if your variable returns one it would work. Quite probably it's not a field else an independent variable and here you need a different approach, for example like:

if($(var) = 'Condition', count(distinct field))

If the variable contains just a boolean you could also use:

count(distinct field) * $(var)

- Marcus

WonderMan
Contributor II
Contributor II
Author

Thank you so much! it worked