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: 
richard_chilvers
Specialist
Specialist

Function for values in a date range ?

Like many, I need often to find whether a date value falls within a date range. For example, in a chart expression.

I have tried to find a function for this eg. InDateRange(date_value,from_date, to_date) but cannot find one.

Of course, I can use nested IFs but was hoping there is a function to make it neater.

Any ideas?

Thanks

Labels (1)
6 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Intervalmatch may be you're looking for. But it's only available in the load script. Otherwise you're indeed limited to and if statement like if(Mydate >= StartDate and Mydate <= EndDate, 1,0)


talk is cheap, supply exceeds demand
richard_chilvers
Specialist
Specialist
Author

Hi

Thanks for your very fast response !

My understanding is that IntervalMatch is a scripting function (to filter the data loaded).

I want to load 3 year's worth of data (say) and let the user enter start and end dates on the information they wish to view in a chart.

Not applicable

Hi

you have to use the set analysis expression for the date field

for exm

sum({$<Date = {">=$(vStartDate)<=$(vEndDate)"}>} SalesValue)

here vstartdate and venddate are variables

it gives the values for this range only

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Intervalmatch is a scripting function, but not to filter out data, but to match it with intervals. Often this is used to match a date with a period. But it can also be used for other intervals.

I've attached a qvw file with an example using input boxes to enable users to select an interval and show the relevant data. I hope this helps you.


talk is cheap, supply exceeds demand
richard_chilvers
Specialist
Specialist
Author

Thanks for your help

richard_chilvers
Specialist
Specialist
Author

Hi - that's helpful, thanks.