Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
jwaligora
Creator II
Creator II

Set Expressions - Which Approach is Preferred?

Which of the two options below is the preferred one (and why)?

  • only({1<Date={"=Date=today()"}>} Month)
  • only({1<Date={"$(=today())"}>} Month)

...this is just an example for illustrative purposes; in practice, 'Month' is a custom time period of lesser granularity than 'Date'. 

Labels (2)
1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Well, the differences are very subtle, and in most cases, hardly noticeable.

The second option is slightly better than the first, however it's not the best syntax either. Let's explain why:

1. The first expression contains "advanced search", or an expression search. It adds a bit of an overhead, somewhat similar to the overhead of an AGGR() function. If the Date field had high cardinality (most likely it doesn't, unless it contains timestamps), the overhead could be noticeable. The only advantage of this approach is the ability not to worry about the date formatting. 

2. The second formula contain a "simple search", which is searching for the value that is returned by the function Today(). It doesn't add the same overhead, because it doesn't contain an implied aggregation. Here you do need to worry about the date format. If your Date field is formatted as a dual date value, then the $-sign expansion needs to be enclosed in single quotes, I believe.

3. The last formula is not optimal in my opinion, because it's also an overkill. There is no need to search for anything. You simply need to select a single value in the field Date. This can be done without the search (without the double quotes):

  • only({1<Date={'$(=today())'}>} Month)

The single quotes here are used to format the date properly. If the field Date is numeric, then the quotes are not needed.

I hope this is helpful. If you'd like to learn more advanced Set Analysis techniques, consider attending the live Masters Summit for Qlik event, which is coming up this fall. Stay tuned for dates and locations that will be published soon.

View solution in original post

1 Reply
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Well, the differences are very subtle, and in most cases, hardly noticeable.

The second option is slightly better than the first, however it's not the best syntax either. Let's explain why:

1. The first expression contains "advanced search", or an expression search. It adds a bit of an overhead, somewhat similar to the overhead of an AGGR() function. If the Date field had high cardinality (most likely it doesn't, unless it contains timestamps), the overhead could be noticeable. The only advantage of this approach is the ability not to worry about the date formatting. 

2. The second formula contain a "simple search", which is searching for the value that is returned by the function Today(). It doesn't add the same overhead, because it doesn't contain an implied aggregation. Here you do need to worry about the date format. If your Date field is formatted as a dual date value, then the $-sign expansion needs to be enclosed in single quotes, I believe.

3. The last formula is not optimal in my opinion, because it's also an overkill. There is no need to search for anything. You simply need to select a single value in the field Date. This can be done without the search (without the double quotes):

  • only({1<Date={'$(=today())'}>} Month)

The single quotes here are used to format the date properly. If the field Date is numeric, then the quotes are not needed.

I hope this is helpful. If you'd like to learn more advanced Set Analysis techniques, consider attending the live Masters Summit for Qlik event, which is coming up this fall. Stay tuned for dates and locations that will be published soon.