Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Amit_B
Creator
Creator

Is current date in the selected range?

Hi,

I need to create a measure that uses a condition based on checking if the current date is part of the selected range. The selection does not have to be on the Date field, but also with other field (Year, Month, Quarter, YTD, MTD).

For example:

Date=03/10/24-03/14/24 --> Current Date is in the selected range.

Year=2024 --> Current Date is in the selected range.

Year=2024, Month=2 --> Current Date is not in the selected range.

Clear all selection --> Current Date is in the selected range (no selection was made so all dates are in the range).

Hope I was clear.

Thanks.

 

Labels (2)
1 Solution

Accepted Solutions
Amit_B
Creator
Creator
Author

Solution:

If(Max(Date) = Max({1} Date), ...)

View solution in original post

5 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Isn't that automatic in Qlik?

-Rob

Amit_B
Creator
Creator
Author

I need to write a condition that will perform a calculation based on the user's selections. If the current date is part of the selected range then measure X will be calculated, otherwise measure Y will be calculated. Both measures will perform the calculation correctly for the selected dates range, the question is which index will be displayed.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think something along the lines of 

if(Date = Only({$} Date), Sum({1} Sales), Sum({1} Margin)

In the mesures (Sum used as example here) you may want to use something other than {1}, perhaps instead using modifiers to ignore the date selection(s) -- depends on your requirement. 

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

Amit_B
Creator
Creator
Author

Sorry but I didn't understand how to set the condition. I also checked this Only function, but I couldn't find a solution.

I created a KPI that will display 1 if the current date is in the selected range, or 0 if not. I selecting only Year value, so if I select 2024 than I recieve 1, else 0.

Amit_B
Creator
Creator
Author

Solution:

If(Max(Date) = Max({1} Date), ...)