Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
demaina
Contributor II
Contributor II

Filter a table with variables

Hello,

I have 1 table with [ID] [date] [availability] [status], this is an example of my dataset :

ID Date Availability Status
1 09/10/2023 yes Working
2 09/10/2023 yes Learning
3 09/10/2023 yes Working
4 09/10/2023 no Off
1 10/10/2023 no Off
2 10/10/2023 yes Working
3 10/10/2023 yes Worlking
4 10/10/2023 yes Learning

 

I put 2 dates picker and my goal is to compare 2 dates in order to know who enter the company or who left the company between the two dates. I have 2 variables with the 2 dates chosen if it could help : vDate1="09/10/2023" and vDate2="10/10/2023"

The result should be in that case :

Newcomers (persons who were not available in Date1 and avaiable in Date2)

4 09/10/2023 no Off
4 10/10/2023 yes Learning

 

Outgoing (persons where ( (date=Date1 and Availability="yes") and (date=Date2 and Availability="no") ) )

1 09/10/2023 yes Working
1 10/10/2023 no Off

 

I don't manage to create this tables, my expressions don't work...

Could you please help me ?

Labels (4)
5 Replies
ajaykakkar93
Specialist III
Specialist III

Hi,

Set analysis can be used to create a date range 

Example:
SUM({<[Term Date] = {">=01/01/2023<=03/31/2023"}>}[Profit USD])

TO

SUM({<[Term Date] = {">=$(vMinDate)<=$(vMaxDate)"}>}[Profit USD])

Where vMinDate & vMaxDate are variables what gives the output for the same

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting

demaina
Contributor II
Contributor II
Author

Thank you but I don't really understand how I can use it in my example... 

ajaykakkar93
Specialist III
Specialist III

Hi,

Lets assume the field [Term Date] has below dates

[Term Date] 

01/12/2022
02/12/2022
03/12/2022
04/12/2022
05/12/2022
etc...

 


steps

  1. Create variables vMinDate with expression
    =date(min([Term Date] ))
  2. Create variables vMaxDate with expression
    =date(max([Term Date] ))
  3. Then in your measure add a set analysis
    =SUM({<[Term Date] = {">=$(vMinDate)<=$(vMaxDate)"}>}[Profit USD])

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting

demaina
Contributor II
Contributor II
Author

Hello ajaydkakkar, maybe my expectations weren't clear. 

 I want to have the list of ID that matches the following conditions : (Date=Date1 and Availability=No) and (Date=Date2 and Avaibability=Yes)

Do you have an idea on how to do that ? 

ajaykakkar93
Specialist III
Specialist III

Yes that can be done with thew same above method

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting