Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Amen_90
Contributor II
Contributor II

Top values based on Aggr across multiple products and differing live dates

Hey Guys, 

I was hoping someone might be able to guide / help me. So I want to create an index chart for product sales which is based on live date that can be variable across different customers and products. 

Lets say in my example below I want to to know product growth based on the live date for a specific account that is July-22. 
Lets also say this is my Raw data below:

Date Live_Date Account Product Sales
Jan-22 July-22 A Apple 1
Feb-22 July-22 A Apple 2
Mar-22 July-22 A Apple 3
Apr-22 July-22

A

Apple 4
May-22 July-22 A Apple 5
Jun-22 July-22 A Apple 6
Jul-22 July-22 A Apple 7
Aug-22 July-22 A Apple 8
Sep-22 July-22 A Apple 9
Oct-22 July-22 A Apple 10
Nov-22 July-22 A Apple 11
Dec-22 July-22 A Apple 12
Jan-22 July-22 A Samsung 2
Feb-22 July-22 A Samsung 4
Mar-22 July-22 A Samsung 6
Apr-22 July-22 A Samsung 8
May-22 July-22 A Samsung 10
Jun-22 July-22 A Samsung 12
Jul-22 July-22 A Samsung 14
Aug-22 July-22 A Samsung 16
Sep-22 July-22 A Samsung 18
Oct-22 July-22 A Samsung 20
Nov-22 July-22 A Samsung 22
Dec-22 July-22 A Samsung 24


I have figured out through reading the forms that I can grab the top sales value across all my dimension by running the following measure expression;

aggr(Top(Sum(Sales)),Product, (Date,(Numeric, ASCENDING)))

Which gives me a table that looks like this;

Date Live_Date Account Product Sales Top
Jan-22 July-22 A Apple 1 1
Feb-22 July-22 A Apple 2 1
Mar-22 July-22 A Apple 3 1
Apr-22 July-22

A

Apple 4 1
May-22 July-22 A Apple 5 1
Jun-22 July-22 A Apple 6 1
Jul-22 July-22 A Apple 7 1
Aug-22 July-22 A Apple 8 1
Sep-22 July-22 A Apple 9 1
Oct-22 July-22 A Apple 10 1
Nov-22 July-22 A Apple 11 1
Dec-22 July-22 A Apple 12 1
Jan-22 July-22 A Samsung 2 2
Feb-22 July-22 A Samsung 4 2
Mar-22 July-22 A Samsung 6 2
Apr-22 July-22 A Samsung 8 2
May-22 July-22 A Samsung 10 2
Jun-22 July-22 A Samsung 12 2
Jul-22 July-22 A Samsung 14 2
Aug-22 July-22 A Samsung 16 2
Sep-22 July-22 A Samsung 18 2
Oct-22 July-22 A Samsung 20 2
Nov-22 July-22 A Samsung 22 2
Dec-22 July-22 A Samsung 24 2

 

However, where I am struggling now is when wanting the Top value to be that of the Live date. Bearing in mind that I have multiple accounts which all have different live dates so I cannot hard code it as a set. When I apply the following expression to try get the top value as per the live date I get it filled in with Zeros as per the aggr expression I am using:

Aggr(top(Sum(if(Date>= Live_Date, Sales))),Product,(Date,(Numeric, ASCENDING)))

The table looks like this:

Date Live_Date Account Product Sales Top
Jan-22 July-22 A Apple 1 0
Feb-22 July-22 A Apple 2 0
Mar-22 July-22 A Apple 3 0
Apr-22 July-22

A

Apple 4 0
May-22 July-22 A Apple 5 0
Jun-22 July-22 A Apple 0 0
Jul-22 July-22 A Apple 7 0
Aug-22 July-22 A Apple 8 0
Sep-22 July-22 A Apple 9 0
Oct-22 July-22 A Apple 10 0
Nov-22 July-22 A Apple 11 0
Dec-22 July-22 A Apple 12 0
Jan-22 July-22 A Samsung 2 0
Feb-22 July-22 A Samsung 4 0
Mar-22 July-22 A Samsung 6 0
Apr-22 July-22 A Samsung 8 0
May-22 July-22 A Samsung 10 0
Jun-22 July-22 A Samsung 12 0
Jul-22 July-22 A Samsung 14 0
Aug-22 July-22 A Samsung 16 0
Sep-22 July-22 A Samsung 18 0
Oct-22 July-22 A Samsung 20 0
Nov-22 July-22 A Samsung 22 0
Dec-22 July-22 A Samsung 24 0

 

What I think is going wrong here is that that the sales have been reduced to just from July onwards, but the function is filling in dates that are not in scope with 0, so top returns the 0.  I've tried added null() to the sum if statement but nothing seems to be working for me.

What I would like my table to look like is this (where the - is null):

Date Live_Date Account Product Sales Top
Jan-22 July-22 A Apple 1 -
Feb-22 July-22 A Apple 2 -
Mar-22 July-22 A Apple 3 -
Apr-22 July-22

A

Apple 4 -
May-22 July-22 A Apple 5 -
Jun-22 July-22 A Apple 0 -
Jul-22 July-22 A Apple 7 7
Aug-22 July-22 A Apple 8 7
Sep-22 July-22 A Apple 9 7
Oct-22 July-22 A Apple 10 7
Nov-22 July-22 A Apple 11 7
Dec-22 July-22 A Apple 12 7
Jan-22 July-22 A Samsung 2 -
Feb-22 July-22 A Samsung 4 -
Mar-22 July-22 A Samsung 6 -
Apr-22 July-22 A Samsung 8 -
May-22 July-22 A Samsung 10 -
Jun-22 July-22 A Samsung 12 -
Jul-22 July-22 A Samsung 14 14
Aug-22 July-22 A Samsung 16 14
Sep-22 July-22 A Samsung 18 14
Oct-22 July-22 A Samsung 20 14
Nov-22 July-22 A Samsung 22 14
Dec-22 July-22 A Samsung 24 14

 

Ultimately the this is going to be used in an indexed line graph from the Live date for each account. The functionality would require the user to select an account before the chart is displayed. 

Any help would be greatly appreciated. 

 

Labels (2)
0 Replies