Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Filtering based on custom condition

Hi all

here my requirement is to show when i select  yes in flag filter it should show total cost in 2015 year(241 dollars)

for instance :

if i select YES it should show total five records(records with yes and no flag)

if i select NO it should show only records with no flag


Please check the Attachment for details

swuehlstevedark

filter issue.png

1 Solution

Accepted Solutions
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

I like to solve these kind of things in the data model, if you add this table and use Flag2 it will work:

LOAD

  Flag,Flag2

INLINE [

Flag,Flag2

No,Yes

Yes,Yes

Yes,No

];

You can then choose to rename fields, so Flag2 is called Flag, and you can even use a HidePrefix so that the join key is not visible.

Stefan's set analysis based answer will also work for you.


Steve

View solution in original post

8 Replies
swuehl
MVP
MVP

Try as expression

=Sum ({<Flag += {'No'}>}TotalCost)

Not applicable
Author

Hi

pls have a look

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

I like to solve these kind of things in the data model, if you add this table and use Flag2 it will work:

LOAD

  Flag,Flag2

INLINE [

Flag,Flag2

No,Yes

Yes,Yes

Yes,No

];

You can then choose to rename fields, so Flag2 is called Flag, and you can even use a HidePrefix so that the join key is not visible.

Stefan's set analysis based answer will also work for you.


Steve

Anonymous
Not applicable
Author

yes its working fine with total cost but my requirement need to show all records in table also(when select yes it should show all records in table )

Select YES it should show all records in table

select NO it should show only records with NO flag

swuehl
MVP
MVP

If you generally need to show all records with flag Yes or No when selecting in listbox 'Yes', then go with the script solution suggested by Steve Dark.

If you need to show a table with all records, but it is on the same page / chart also required to filter on records using the specific selected value, then you might want to consider a set analysis solution.

You can also combine both solutions.

For example, to show all records, create a straight table with the all the fields you want to show as dimensions, and use an expression (that you can hide on presentation tab) like

=Count ({<Flag += {'No'}>}TotalCost)

gowtham_patnaik
Contributor III
Contributor III

try this:

=if(Flag='Yes',sum({1}TotalCost),sum({$<flag={'No'}>}TotalCost))

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

The script solution is generally good, but you have to be *really* careful if you are putting the dimension in a table.  The way that one dim links to two will cause duplication of rows (if you put Flag2 in the table after usuing my script).

If you only use Flag2 in listboxes and Flag in tables, then everything will work fine.

Set analysis allows you to be more prescriptive about what happens where.

Steve

Anonymous
Not applicable
Author

yeah steve its working fine i used Flag2 as in filter and flag used in chart expressions