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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count distinct Cumulative

Hello all,

I need some help to resolve a problem to calculate a cumulative count distinct.

I want to calculate how customers I have from the beginning till the last quarter/year.

I load this data :

  

Quarter_yearCustomerSales
2013_Q1A11
2013_Q1A22
2013_Q1A33
2013_Q1A14
2013_Q2A15
2013_Q2A36
2013_Q2A47
2013_Q3A18
2013_Q3A59
2013_Q3A610
2013_Q4A111
2013_Q4A612
2013_Q4A713
2014_Q1A314
2014_Q1A415
2014_Q1A816
2014_Q2A317
2014_Q2A418
2014_Q2A819
2014_Q2A920
2014_Q2A1021

And I want to have this "result" :

  

Quarter_yearResult
2013_Q13
2013_Q24
2013_Q36
2013_Q47
2014_Q18
2014_Q210

For 2013_Q1 : count distinct customer from 2013_Q1

uarter_yearCustomerSales
2013_Q1A11
2013_Q1A22
2013_Q1A33
2013_Q1A14

For 2013_Q2 : count distinct customer from all customers in  ( 2013_Q1 and 2013_Q2)

Quarter_yearCustomerSales
2013_Q1A11
2013_Q1A22
2013_Q1A33
2013_Q1A14
2013_Q2A15
2013_Q2A36
2013_Q2A47

For 2014_Q1 : Count distinct customer from all customers in (2013_Q1, 2013_Q2, 2013_Q3, 2013_Q4, 2014_Q1°

Quarter_yearCustomerSales
2013_Q1A11
2013_Q1A22
2013_Q1A33
2013_Q1A14
2013_Q2A15
2013_Q2A36
2013_Q2A47
2013_Q3A18
2013_Q3A59
2013_Q3A610
2013_Q4A111
2013_Q4A612
2013_Q4A713
2014_Q1A314
2014_Q1A415
2014_Q1A816

Thank you.

1 Solution

Accepted Solutions
sunny_talwar

New Expression:

=If(Only({<Quarter_year = , Quarter_Year_Num = >} Quarter_Year_Num) <= Max(TOTAL Quarter_Year_Num),

Count({<Quarter_year = , Quarter_Year_Num = >}Aggr(Count({<Quarter_year = , Quarter_Year_Num = >}Customer), Customer)))


NOTE: Make sure 'Full Accumulation' in checked:


Capture.PNG

View solution in original post

6 Replies
sunny_talwar

See if the attached helps:

Expression:

=If(KeepChar(Only({<Quarter_year = >}Quarter_year), '0123456789') <= Max(TOTAL KeepChar(Quarter_year, '0123456789')),

Count({<Quarter_year = >}Aggr(Count({<Quarter_year = >}Customer), Customer)))

Capture.PNG

Capture.PNG

Not applicable
Author

Thank you for your help.

It works when I use the function "KeepChar(Quarter_year, '0123456789')".

In my application, I transform quarter year into number like : left(Quarter_year,4)*4+right(Quarter_year,1) :

the quarter_year_num  let me compare data for différent quarter year.

example :

 

Quarter_yearQuarter_Year_Num
2013_Q18053
2013_Q28054
2013_Q38055
2013_Q48056
2014_Q18057
2014_Q28058

when I use this expression, it doesn't work :

=If(Quarter_Year_Num <= Max(TOTAL Quarter_Year_Num),

Count({<Quarter_year = >}Aggr(Count({<Quarter_year = >}Customer), Customer)))

sunny_talwar

And where are you making selection for quarter? In Quarter_year or Quater_Year_Num list box?

sunny_talwar

New Expression:

=If(Only({<Quarter_year = , Quarter_Year_Num = >} Quarter_Year_Num) <= Max(TOTAL Quarter_Year_Num),

Count({<Quarter_year = , Quarter_Year_Num = >}Aggr(Count({<Quarter_year = , Quarter_Year_Num = >}Customer), Customer)))


NOTE: Make sure 'Full Accumulation' in checked:


Capture.PNG

Not applicable
Author

In quarter year.

Not applicable
Author

Thank you for your help