Announcements
Applications are open for the 2024 Qlik Luminary Program. Apply by December 15 here.
cancel
Showing results for
Did you mean:
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.

Labels (5)

• ### Set Analysis

2 Solutions

Accepted Solutions
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.

MVP & Luminary

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

4 Replies
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.

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.
MVP & Luminary

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

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.

Tags
Community Browser