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: 
rdugg
Contributor III
Contributor III

Use complex set analysis to combine filters on a table

I'm trying to have a fixed (hardcoded) filter on a table of multiple dimensions to filter data while that filter not being user editable.

I see how set analysis can be used on measures but I cannot find a way to filter dimensions of my table.

I guess i could use an alternate state an the whole table but I don't see a function/action to set my alternate state to a specific complex set.

example :

I have following dimensions 

  •  vehicle : car, train, boat, plane, bike
  •  color: red, blue, green,
  •  weight: (kg)
  • hasWheels

I would like to filter: 

  • red cars under 500KG and above 2500 kg
  • and, blue trains
  • and, boats with wheels
  • and, bikes above 200 kg

The idea is to highlight a set of the data source where inconsistencies has been seen, and get a list of these inconsistencies to quantify them.

I guess a set analysis with all those rules could be hardcoded as a state, because an alternate state can then be used upon a table.

but then, the alternate state can be modified by a user using the gui (and we don't want that).

Then how to set the alternate state to these rules.

Is there a function like setAlternateStateTo('stateName', 'set analysis string') that I could use as an action when the sheet loads. Or can we apply an unnamed alternate state (just by defining the filter) to a table object ?

Labels (2)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

If you apply those sets within the Measure, it will by default filter the Dimensions. 

If you want to filter the Dimensions directly, you can do by creating a Calculated Dimension using Aggr and Only. 

Aggr(
Only(
{<

vehicle = {'car'},
color = {'red'},
weight = {"<500 >2500"}
>} Name
)
,Name)

View solution in original post

4 Replies
Clement15
Partner - Specialist
Partner - Specialist

Does something like this work for you?

Count(
{<
vehicle = {'car'},
color = {'red'},
weight = {"<500 >2500"}
>} DISTINCT id
)
+
Count(
{<
vehicle = {'train'},
color = {'blue'}
>} DISTINCT id
)
+
Count(
{<
vehicle = {'boat'},
hasWheels = {1}
>} DISTINCT id
)
+
Count(
{<
vehicle = {'bike'},
weight = {">200"}
>} DISTINCT id
)

marcus_sommer

Just combine the conditions with an OR operator and maybe also using 1 as identifier - it may look like:

count({1< Set1 > + < Set2 >} field)

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

If you apply those sets within the Measure, it will by default filter the Dimensions. 

If you want to filter the Dimensions directly, you can do by creating a Calculated Dimension using Aggr and Only. 

Aggr(
Only(
{<

vehicle = {'car'},
color = {'red'},
weight = {"<500 >2500"}
>} Name
)
,Name)

rdugg
Contributor III
Contributor III
Author

Thank you

It works but the Aggr(Only({...rules...})) has to be copied in each column expressions 😕

I guess I have to find a way to put the ...rules... part in a variable then to have that logic defined one time only.