Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
WEBINAR June 25, 2025: Build on Apache Iceberg with Qlik Open Lakehouse - REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
shep_work
Contributor III
Contributor III

Filter a table based on a variable syntax problem

I have a table and I want to filter the records based on a choice of a variable that is being set via a button in the master item list.  I think I have done this before but just can't find the reference I used or a answered question in the forums that does this for Qlik Sense in specific. Please help.

The purpose is to show differences in 'Regular' employees vs 'Campus/Interns'.  The field on each row is EXCLUDE_FROM_COUNTS, with 1 for Yes (exclude, aka interns) and 0 for No (include, aka regular).

The Variable is 'vEE_TYPES' where the values are either 'REGULAR' or 'CAMPUS-INTERN'.

 

I have a sample working measure/count filter, but I need a dimension/row filter.

My working code that will show counts based on the variable:

=IF('$(vEE_Types)'='REGULAR',Count({<EXCLUDE_FROM_COUNTS = {0}>} ID),
	IF('$(vEE_Types)'='CAMPUS-INTERN',Count({<EXCLUDE_FROM_COUNTS = {1}>} ID),0
      ) 
    )

 

My ham-fisted attempt to do this as a calculated dimension that gets 'error in expression' but no clue why:

=IF('$(vEE_Types)'='REGULAR',IF(Aggr(Count({<EXCLUDE_FROM_COUNTS = {0}>}),ID)>=1,ID),
	IF('$(vEE_Types)'='CAMPUS-INTERN',IF(Aggr(Count({<EXCLUDE_FROM_COUNTS = {1}>}),ID)>=1,ID),Null
    	)
    )

 

Labels (1)
1 Solution

Accepted Solutions
henrikalmen
Specialist II
Specialist II

You're not counting anything. You have basically written aggr(count(), ID)

=IF('$(vEE_Types)'='REGULAR',IF(Aggr(Count({<EXCLUDE_FROM_COUNTS = {0}>} add_something_to_count_here),ID)>=1,ID),
IF('$(vEE_Types)'='CAMPUS-INTERN',IF(Aggr(Count({<EXCLUDE_FROM_COUNTS = {1}>} add_something_to_count_here),ID)>=1,ID),Null
    )
    )

In your first expression, the working one, you're counting ID but here you are doing an aggregation of "nothing" over ID.

View solution in original post

2 Replies
henrikalmen
Specialist II
Specialist II

You're not counting anything. You have basically written aggr(count(), ID)

=IF('$(vEE_Types)'='REGULAR',IF(Aggr(Count({<EXCLUDE_FROM_COUNTS = {0}>} add_something_to_count_here),ID)>=1,ID),
IF('$(vEE_Types)'='CAMPUS-INTERN',IF(Aggr(Count({<EXCLUDE_FROM_COUNTS = {1}>} add_something_to_count_here),ID)>=1,ID),Null
    )
    )

In your first expression, the working one, you're counting ID but here you are doing an aggregation of "nothing" over ID.

shep_work
Contributor III
Contributor III
Author

Thanks! that did it, I was just missing something super obvious, lol