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

Distinct diagram cumulation

Hello Community,

I want to export an up-to-now manually created report (that my company has used for years) to Qlikview and I'm running into some problems.

The idea is to track the activity of a defined group of customers over a certain time and see how the activity percentage rises over time (here from week to week).

Therefore a span of weeks is defined and the number of unique customers is tracked and cumulated per week.

Example:

3 tracked weeks

9 Total Customers in observed group

6 Customers  bought something (1 is a transaction):

  

CustomerIDWeek 1Week 2Week 3
Customer1111
Customer21-1
Customer31--
Customer4-1-
Customer5-1-
Customer6--1

So for example customer 1 is active in all 3 weeks

and customer 3 only in week 1.

Therefore the counted unique customers (6 of 9 bought once or more in the 3 weeks) would be in each week:

  

Week TotalWeek 1Week 2Week 3
count(distinct CustomerID)6333
count( {<Week=>} total distinct CustomerID)9999

When these are cumulated over time I get (complete accumulation in the formula tab):

  

WeekTotalWeek 1Week 2Week 3
count(distinct CustomerID)6369
count( {<Week=>} total distinct CustomerID)9999
Activity Percentage33%67%100%

But that's not what I want because customers who bought in 2 or more weeks get counted once for every week they bought something in.

The right cumulation without double entries should result in:

  

WeekTotalWeek 1Week 2Week 3
right cumulation6356
=count( {<Week=>} total distinct CustomerID)9999
Activity Percentage33%56%67%

But that is wrong, because actually only 6 out of 9 bought something, but the cumulation just adds up the numbers of each week and therefore, because some people buy something in 2 or more weeks, the activity percentage is too high in the end.

I understand that Qlikview treats the DISTINCT per customer per week and not per customer in total, but I didn't find a solution yet.

So is there any way to only cumulate up to the real distinct number over the weeks (here 6) without double counting customers who bought multiple times over these weeks?

Thank you very much in advance!

1 Solution

Accepted Solutions
sunny_talwar

Use AsOfTable approach

Sales:

Load * Inline [

"Week"|"Sales"|"CustomerID"

1|1|Customer1

1|1|Customer2

1|1|Customer3

2|1|Customer4

2|1|Customer5

2|1|Customer1

3|1|Customer6

3|1|Customer1

3|1|Customer2

] (delimiter is '|');

MinWeek:

LOAD Min(Week) as MinWeek

Resident Sales;

LET vMinWeek = Peek('MinWeek');

DROP Table MinWeek;

Customers:

NoConcatenate

Load * Inline [

"CustomerID"

Customer1

Customer2

Customer3

Customer4

Customer5

Customer6

Customer7

Customer8

Customer9

];

AsOfWeek:

LOAD DISTINCT Week as AsOfWeek,

(Week - IterNo() + 1) as Week

Resident Sales

While (Week - IterNo() + 1) >= $(vMinWeek);

Dimension:

AsOfWeek

Expression

count(distinct CustomerID)

Check 'No Accumulation' instead of 'Full Accumulation'

Capture.PNG

View solution in original post

2 Replies
sunny_talwar

Use AsOfTable approach

Sales:

Load * Inline [

"Week"|"Sales"|"CustomerID"

1|1|Customer1

1|1|Customer2

1|1|Customer3

2|1|Customer4

2|1|Customer5

2|1|Customer1

3|1|Customer6

3|1|Customer1

3|1|Customer2

] (delimiter is '|');

MinWeek:

LOAD Min(Week) as MinWeek

Resident Sales;

LET vMinWeek = Peek('MinWeek');

DROP Table MinWeek;

Customers:

NoConcatenate

Load * Inline [

"CustomerID"

Customer1

Customer2

Customer3

Customer4

Customer5

Customer6

Customer7

Customer8

Customer9

];

AsOfWeek:

LOAD DISTINCT Week as AsOfWeek,

(Week - IterNo() + 1) as Week

Resident Sales

While (Week - IterNo() + 1) >= $(vMinWeek);

Dimension:

AsOfWeek

Expression

count(distinct CustomerID)

Check 'No Accumulation' instead of 'Full Accumulation'

Capture.PNG

Anonymous
Not applicable
Author

Seems to work fine, thank you