Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Shoban_01
Partner - Contributor II
Partner - Contributor II

Date Range

This is my requirement, like using a date to filter some dimensions.

The default date range is working well. But I need some dimension selections to change the date range based on that dimension level.

Example: Default Date Range

From is 02/20/2023

To is 02/21/2024 

User requirement:  Selected  some dimension values, 

like Name (Raja), it should display the employee joining date is 03/05/2023 termination date is 09/06/2023

Before:

From is 02/20/2023

To is 02/21/2024 

After:

From is 03/05/2023

To is 09/06/2023

2 Replies
G3S
Creator III
Creator III

it would be a combination of the min and max of the date field. 

Aasir
Creator III
Creator III

Creating variable could help you in this specific case.

// Default date range
vFromDate = Date('02/20/2023', 'MM/DD/YYYY');
vToDate = Date('02/21/2024', 'MM/DD/YYYY');

// Flag for dimension selection
vNameSelected = 0;

The use below expression for set it

// For charts using the default date range
Sum({<DateField={">=$(vFromDate)<=$(vToDate)"}>} Sales)

// For charts adjusting the date range based on the selected Name
Sum({<DateField={">=$(=if(vNameSelected, Date('03/05/2023', 'MM/DD/YYYY'), vFromDate))<=$(=if(vNameSelected, Date('09/06/2023', 'MM/DD/YYYY'), vToDate))"}>} Sales)

then once a selection done trigger to set vNameSelected to 1 when a Name is selected
SET vNameSelected = 1;

Can adjust the variables created based on selection

// Adjust the date range based on the selected Name
IF vNameSelected THEN
SET vFromDate = Date('03/05/2023', 'MM/DD/YYYY');
SET vToDate = Date('09/06/2023', 'MM/DD/YYYY');
ELSE
SET vFromDate = Date('02/20/2023', 'MM/DD/YYYY');
SET vToDate = Date('02/21/2024', 'MM/DD/YYYY');
END IF;

This will dynamically adjust the date range based on the selected dimensions