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

Use a variable in set analysis

Hii,

In the script, I declare my variable vMoins6mois 1.JPG

and in the set analysis I want to count idAP that has a date lower than the declared variable  2.JPG

but it's not okay ...

I use Qlik Sense Enterprise September 2018 SR2

Thanks for help

Clem

Labels (1)
3 Replies
Gysbert_Wassenaar

First remove the = character from your measure expression.

 And please post expressions as text instead of as screenshots. It's darn hard to copy text from images. 


talk is cheap, supply exceeds demand
clemenceabad
Contributor III
Contributor III
Author

Sorry, I removed = character like that

count({$<dateAPAC={"<$(vMoins6mois)"}>}distinct idAP) but it doesn't work.

For example vMoins6mois=date(Date-183,'DD/MM/YYYY')

I select 2018 october 1st with Date filter, so vMoins6mois= 2018 april 1st and I want to count idAP before this date.

The current result is 0... although there are idAP with a lower date

chriscammers
Partner - Specialist
Partner - Specialist

the expression you have in the variable is "Date-183" a reference to a field in your data model or another variable?

I'm going to assume it is a field.

The first thing I would do is to make sure the date fields in your data are stored in the default qlik date format, an easy way to do this is to load the date fields within Date(Num(Field)). Then when you do your search in Set analysis you don't get messed up by weird date formatting problems.

 

Then I would build you Set Analysis in layers...

  1. Does "Count(Distinct idAP)" work?
  2. Count({$<dateAPAC = {"<1/1/2018"}>}Distinct idAP) 
  3. Count({$<dateAPAC = {"$(='<' & Date(Max(Date-183))"}>}Distinct idAP) 

I think my third example is probably the one that will work for you