Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Xerxes
Contributor II
Contributor II

Set Analysis with multiple conditions

My old set analysis skills are lost.

I have tried so many versions of below code without success.

Below version gives me the correct count for the date but does not apply the other modifiers.

Count(Distinct ${<import_date={"=(vMax_import_date)"}, days_late={">0 <31"}, brand={"Nike", "Puma"}>} account_id)

The variable vMax_import_date is max(import_date)

And below version gives me the correct count but the date is hard coded which it cannot be in the app.

Count(Distinct{<import_date={"2020-06-21"}, days_late={">0 <31"}, brand={"Nike", "Puma"}>} account_id)

Qlik since 2006
1 Solution

Accepted Solutions
Xerxes
Contributor II
Contributor II
Author

Yes, close enough!

Moving the $ into the bracket worked.

Count(Distinct {$<import_date={"$(=Date(Max(import_date),'YYYY-MM-DD'))"}, days_late={">0 <31"}, brand={"Nike", "Puma"}>} account_id)
Qlik since 2006

View solution in original post

6 Replies
shanemichelon
Partner - Creator II
Partner - Creator II

Try This:

 

Count(Distinct {$ <import_date={"=$(vMax_import_date)"}, days_late={">0 <31"}, brand={"Nike", "Puma"}>} account_id)

 

Set analysis needs to be enclosed in curly brackets.  Then the $ symbol is for the current selections, the angled brackets are the modifiers. To get variable values, enclose in dollar sign expansion.

Xerxes
Contributor II
Contributor II
Author

Thanks.

With the suggested solution the date filter is not applied, the days_late and brand are applied so the result is the same as if I remove the date.

Qlik since 2006
shanemichelon
Partner - Creator II
Partner - Creator II

Sorry, I just noticed your date variable is Max(import_date).  This give a numeric result.  You need to turn that back into a date with the Date function.  You can do it in the variable or in the set analysis:

Count(Distinct {$ <import_date={"=$(=Date(vMax_import_date))"}, days_late={">0 <31"}, brand={"Nike", "Puma"}>} account_id)

 

In QS expression editor you should be able to see the result of the set analysis at the bottom.

NitinK7
Specialist
Specialist

Hi,

try below expression

Count(Distinct ${<import_date={"$(=Date(Max(import_date),'YYYY-MM-DD'))"}, days_late={">0 <31"}, brand={"Nike", "Puma"}>} account_id)

 

Xerxes
Contributor II
Contributor II
Author

This string gives 0 as result ->

Count(Distinct {$ <import_date={"=$(=Date(vMax_import_date))"}, days_late={">0 <31"}, brand={"Nike", "Puma"}>} account_id)

 

Qlik since 2006
Xerxes
Contributor II
Contributor II
Author

Yes, close enough!

Moving the $ into the bracket worked.

Count(Distinct {$<import_date={"$(=Date(Max(import_date),'YYYY-MM-DD'))"}, days_late={">0 <31"}, brand={"Nike", "Puma"}>} account_id)
Qlik since 2006