Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Optimized Aggregations or sums

Hello.

I'm currently building an application and according to the selection of the user, i calculated 20 values and set them as ranges of sales for the chart.  I want to calculate how many customers are in each range using the customer's sales volume data.

In the chart i'm setting the dimensions like this:

=ValueList(

    '$(vRange_001)',

    '$(vRange_002)',

    '$(vRange_003)',

    '$(vRange_004)',

    '$(vRange_005)',

    '$(vRange_006)',

    '$(vRange_007)',

    '$(vRange_008)',

    '$(vRange_009)',

    '$(vRange_010)')


And the expression, i'm using the next:


Pick(RowNo(),
Sum({$<Customer_ID = {"=$($(=sum(Volume)))>=$(vBins_1a) and $($(=sum(Volume)))<$(vBins_1b)"}>} Counter),
Sum({$<Customer_ID = {"=$($(=sum(Volume)))>=$(vBins_2a) and $($(=sum(Volume)))<$(vBins_2b)"}>} Counter),
Sum({$<Customer_ID = {"=$($(=sum(Volume)))>=$(vBins_3a) and $($(=sum(Volume)))<$(vBins_3b)"}>} Counter),
Sum({$<Customer_ID = {"=$($(=sum(Volume)))>=$(vBins_4a) and $($(=sum(Volume)))<$(vBins_4b)"}>} Counter),
Sum({$<Customer_ID = {"=$($(=sum(Volume)))>=$(vBins_5a) and $($(=sum(Volume)))<$(vBins_5b)"}>} Counter),
Sum({$<Customer_ID = {"=$($(=sum(Volume)))>=$(vBins_6a) and $($(=sum(Volume)))<$(vBins_6b)"}>} Counter),
Sum({$<Customer_ID = {"=$($(=sum(Volume)))>=$(vBins_7a) and $($(=sum(Volume)))<$(vBins_7b)"}>} Counter),
Sum({$<Customer_ID = {"=$($(=sum(Volume)))>=$(vBins_8a) and $($(=sum(Volume)))<$(vBins_8b)"}>} Counter),
Sum({$<Customer_ID = {"=$($(=sum(Volume)))>=$(vBins_9a) and $($(=sum(Volume)))<$(vBins_9b)"}>} Counter),
Sum({$<Customer_ID = {"=$($(=sum(Volume)))>=$(vBins_10a) and $($(=sum(Volume)))<$(vBins_10b)"}>} Counter))


So, the performance is slow for the user.

any way to improve this?

Thanks

1 Solution

Accepted Solutions
Nicole-Smith

You should be able to improve on this by using the class() function:

class(expression, interval [ , label [ , offset ]])

Creates a classification of expressions. The bin width is determined by the number set as interval. The result is shown as a<=x<b, where a and b are the upper and lower limits of the bin. The x can be replaced by an arbitrary string stated in label. 0 is normally the default starting point of the classification. This can be changed by adding an offset.

Examples:

class( var,10 ) with var = 23 returns '20<=x<30'

class( var,5,'value' ) with var = 23 returns '20<= value <25'

class( var,10,'x',5 ) with var = 23 returns '15<=x<25'

View solution in original post

2 Replies
Nicole-Smith

You should be able to improve on this by using the class() function:

class(expression, interval [ , label [ , offset ]])

Creates a classification of expressions. The bin width is determined by the number set as interval. The result is shown as a<=x<b, where a and b are the upper and lower limits of the bin. The x can be replaced by an arbitrary string stated in label. 0 is normally the default starting point of the classification. This can be changed by adding an offset.

Examples:

class( var,10 ) with var = 23 returns '20<=x<30'

class( var,5,'value' ) with var = 23 returns '20<= value <25'

class( var,10,'x',5 ) with var = 23 returns '15<=x<25'

Not applicable
Author

Great, the performance is a lot better! Thanks!