Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Jnkansayeboah
Contributor
Contributor

Can I wrap a variable within date parameters within a set expression?

I want to wrap a variable in qliksense within date parameters within a set expression. Is this possible...Below is my code, however I am not sure if it is right. Could someone help please? Thanks.

 

=$(={<[Date]= {"<=$(=Date('31/03/2020')) >=$(=Date('01/04/2019'))"}>} (variable)))

Labels (1)
6 Replies
BjoernWollny
Contributor III
Contributor III

Hi,

can you give a short background of the target you want to achieve - how do you want to use this variable?
In general you can easily use variables in set analysis. How to use them depends on your definitions.

When your Variable contains directly the date entries already separated correctly you can use for example:

sum({<Date={'$(vMyDates)'}>} Sales)

 

but having some more background from your use case, will allow me to give a custom solution for your issue.

Jnkansayeboah
Contributor
Contributor
Author

hi @BjoernWollny ,

Thanks for you response. To give you more clarity, I have a created variable called "TimeToHire". This variable shows me the average time is it takes for employees to be hired at a particular company, from the moment they apply for a job.

I want to create a KPI which constrains the "TimeToHire" variable within a specific time frame. I am not sure if my approach is right or not. 

I hope that makes sense? Could you advise please?

BjoernWollny
Contributor III
Contributor III

Hi,

can you please post the definition of your current variable and maybe also a short example of the result you expect.

From what I understood, I would expect, that you can set this specific time frame directly in the set analysis of your variable

Saravanan_Desingh

I assume that you want to compare the [Date] between 31/3/2020 and 1/4/2019. Let us use COUNT here.

Count({<variable={"=Date([Date],'DD/MM/YYYY')<=Date('31/03/2020','DD/MM/YYYY') And  Date([Date],'DD/MM/YYYY')>=Date('01/04/2019','DD/MM/YYYY')"}>} variable)

If you need something, please let me know.

Jnkansayeboah
Contributor
Contributor
Author

@Saravanan_Desingh 

 

Hi, thanks for your response. I do not want to count the variable. The variable already, gives a number. I just want to constrain it to a certain timeframe.  Does that make more sense?

BjoernWollny
Contributor III
Contributor III

please post your definition of the variable and the timeframe you would like to constrain it to.

Probably you just need to add this timeframe to the set analysis within the variable definition.

 

 

In case you not generally want to add this to your variable and only in some cases, you should work with parameters.

Eg:

//Definition of variable
MyVariable = sum($1 Sales)
MySetAnalysis = {<Date={'>=2/2/2020'}>}
//call of variable without any time frame:
=$(MyVariable())

//call of variable with time frame:
=$(MyVariable($(MySetAnalysis)))