Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Improve expression

How can I improve the following expression

(if(IsNull(GetFieldSelections(Week,'*')),(Sum({$<Year={$(=max(Year))}>}[Prix de vente TTC])-Sum({$<Year={$(=max(Year-1))}>}[Prix de vente TTC]))/Sum({$<Year={$(=max(Year-1))}>}[Prix de vente TTC]),
(Sum({$<Weekyear= {$(=max(Weekyear))}>}[Prix de vente TTC])-Sum({$<Weekyear= {$(=max(Weekyear-1))}>}[Prix de vente TTC]))/Sum({$<Weekyear= {$(=max(Weekyear-1))}>}[Prix de vente TTC])))
1 Reply
marcus_sommer

An improvement could be to change the kind of rate which you calculate from:

(CurrentYear - LastYear) / LastYear

     to

CurrentYear / LastYear

/* or reversed an/or multiplied with 100 or with (-1 + result) or (result -1) to change the direction from the rate*/

with them you could reduce the calculation-steps from four to two.

Further possible is to transfer your week-selections check into a variable which then returned either the year- or the weekyear-expression which meant those check would be only done one time globally and not for each possible record.

Another possibility might be to create boolean flag-fields for current/last year within the script (disadvantage: (really) isn't flexible against user-selections anymore) and use then simplyfied expressions like:

sum([Prix de vente TTC] * CurrentYearFlag)

- Marcus