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: 
anu
Partner - Contributor III
Partner - Contributor III

Dates in Set Analysis

Hi Everyone,

Greetings!

Recently i came across an old app where in set analysis 

Start_Date = {">=$(=Date(Yearstart(Monthstart(Max(Date-0))),'YYYY/MM/DD'))<=$(=Date(Max(Date-0),'YYYY/MM/DD'))"}

is used.

I am puzzled with max(Date-0) in the expression, I checked it in a table's measure and found that it returns numeric value of max(Date).

I am still puzzled and want to know the other possible reasons of why this was used other than changing it to numeric value. Both Start_Date and Date fields have same format i.e YYYY/MM/DD.

Please share your suggestions and experiences.

Labels (5)
2 Solutions

Accepted Solutions
tresesco
MVP
MVP


@anu wrote:

... other than changing it to numeric value


I would assume that the developer had a similar idea in mind, may be considering implicit type casting, however in qlik - it does not work that way. IMO, this '-0' is redundant. Also, monthstart() is another function redundant in this context. 

View solution in original post

marcus_sommer

Even the date() could be removed because the >= respectively <= forced a numerical comparison which means the format is irrelevant and also that yearstart() returned a timestamp and not a date and therefore it could be look like:

Start_Date = {">=$(=Yearstart(Max(Date)))<=$(=Max(Date))"}

- Marcus

View solution in original post

4 Replies
tresesco
MVP
MVP


@anu wrote:

... other than changing it to numeric value


I would assume that the developer had a similar idea in mind, may be considering implicit type casting, however in qlik - it does not work that way. IMO, this '-0' is redundant. Also, monthstart() is another function redundant in this context. 

vinieme12
Champion III
Champion III

this could just be

Start_Date = {">=$(=Date(Yearstart(Max(Date)),'YYYY/MM/DD'))<=$(=Date(Max(Date),'YYYY/MM/DD'))"}

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
marcus_sommer

Even the date() could be removed because the >= respectively <= forced a numerical comparison which means the format is irrelevant and also that yearstart() returned a timestamp and not a date and therefore it could be look like:

Start_Date = {">=$(=Yearstart(Max(Date)))<=$(=Max(Date))"}

- Marcus

anu
Partner - Contributor III
Partner - Contributor III
Author

As Start_Date is without timestamp and app has 35M records, does using Yearstart() without Date() formatting can help in reducing calculation time.