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: 
chloe
Contributor III
Contributor III

Date Picker- default selected date compare to

Hi,

I'm using the Date Picker object while having two calendars in my script.
1. Calendar -  which represent "Current Date"
2. Calendar_2 - which represent "Compare To" 

chloe_0-1637154359486.png

What I want to create is the option that when the user selects the "current date", on default the" compare to" will be on the same days last week. 

 

Is that possible? 

 

Thanks, 

 

Labels (1)
2 Solutions

Accepted Solutions
Andrei_Cusnir
Specialist
Specialist

Hello,

 

If my understanding is correct, you would like to select a date range in the first Date picker, such as from "1/24/2021" to "1/31/2021" and you would like to automatically have the second Date picker select the dates from "1/17/2021" to "1/24/2021", where this range has 7 days difference. 

 

To implement this solution, you will have to attach a trigger action when the Date1 is selected, however natively this is not supported in Date picker object. There is an extension "qlik-sense-action-triggers" [1], that might be able to help you achieve your desired outcome. You can read the details and test the sample app, to get familiar with the extension, however since it is not developed by Qlik, if you have any issues with the outcome, or you need additional help, then you will have to reach to the developer of the extension.

 

Another workaround that can help you achieve a similar outcome is the following:

Note: Please keep in mind that this is just a suggestion and the same use case scenario might be achieved with other options as well. However, this is the one that I have fully tested that is working and it can get you as close as possible to the desired outcome.

 

1. I have the following dataset:

SCREENSHOT

These are data from 2 different tables.

 

2. Create 2 variables:

SCREENSHOT

 

3. Create 2 variable inputs:

SCREENSHOT

I have assigned to the first one the variable varFrom and to the second one the variable varTo

 

4. Create a button with 2 actions:

Both actions have "Select values matching search criteria"  as selected option. However first action has the field Date1 and the second variable has the field Date2.

 

Action 1:

SCREENSHOT

Expression: ='>=$(varFrom)<=$(varTo)'

 

This expression will select the values in field Date1 based on the values that the user has selected in the Variable input objects.

 

Action 2:

SCREENSHOT

Expression: ='>=$(=Date(Date(varFrom)-7))<=$(=Date(Date(varTo)-7))'

This expression will first subtract 7 days from the dates that the user has specified in the Variable input objects and then will make the selection in Date2 filed.

 

After clicking the button this is what I get:

SCREENSHOT

 

As you can see the first selection is the values that the user has specified and the second selection is the same values but 7 days prior. 

 

I hope that this information was helpful. In case this has helped you resolve the issue, please mark the answer as solution to provide further visibility for other community members. In case I have misunderstood the use case scenario, please elaborate in detail by providing additional information. 

 

---

[1] https://github.com/mcgovey/qlik-sense-action-triggers

Help users find answers! Don't forget to mark a solution that worked for you! 🙂

View solution in original post

chloe
Contributor III
Contributor III
Author

Thank you @Andrei_Cusnir  for your help 🙂 

View solution in original post

2 Replies
Andrei_Cusnir
Specialist
Specialist

Hello,

 

If my understanding is correct, you would like to select a date range in the first Date picker, such as from "1/24/2021" to "1/31/2021" and you would like to automatically have the second Date picker select the dates from "1/17/2021" to "1/24/2021", where this range has 7 days difference. 

 

To implement this solution, you will have to attach a trigger action when the Date1 is selected, however natively this is not supported in Date picker object. There is an extension "qlik-sense-action-triggers" [1], that might be able to help you achieve your desired outcome. You can read the details and test the sample app, to get familiar with the extension, however since it is not developed by Qlik, if you have any issues with the outcome, or you need additional help, then you will have to reach to the developer of the extension.

 

Another workaround that can help you achieve a similar outcome is the following:

Note: Please keep in mind that this is just a suggestion and the same use case scenario might be achieved with other options as well. However, this is the one that I have fully tested that is working and it can get you as close as possible to the desired outcome.

 

1. I have the following dataset:

SCREENSHOT

These are data from 2 different tables.

 

2. Create 2 variables:

SCREENSHOT

 

3. Create 2 variable inputs:

SCREENSHOT

I have assigned to the first one the variable varFrom and to the second one the variable varTo

 

4. Create a button with 2 actions:

Both actions have "Select values matching search criteria"  as selected option. However first action has the field Date1 and the second variable has the field Date2.

 

Action 1:

SCREENSHOT

Expression: ='>=$(varFrom)<=$(varTo)'

 

This expression will select the values in field Date1 based on the values that the user has selected in the Variable input objects.

 

Action 2:

SCREENSHOT

Expression: ='>=$(=Date(Date(varFrom)-7))<=$(=Date(Date(varTo)-7))'

This expression will first subtract 7 days from the dates that the user has specified in the Variable input objects and then will make the selection in Date2 filed.

 

After clicking the button this is what I get:

SCREENSHOT

 

As you can see the first selection is the values that the user has specified and the second selection is the same values but 7 days prior. 

 

I hope that this information was helpful. In case this has helped you resolve the issue, please mark the answer as solution to provide further visibility for other community members. In case I have misunderstood the use case scenario, please elaborate in detail by providing additional information. 

 

---

[1] https://github.com/mcgovey/qlik-sense-action-triggers

Help users find answers! Don't forget to mark a solution that worked for you! 🙂
chloe
Contributor III
Contributor III
Author

Thank you @Andrei_Cusnir  for your help 🙂