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: 
lg92
Contributor II
Contributor II

Cumulative distinct count in bar chart

Hi

I have this datset

ID          DATE
3603  01/01/2021
3603  01/02/2021
4076  01/01/2021
4076  01/03/2021
4076  01/02/2021
4101  01/02/2021

I would create a bar chart with 

  • Dim: Date.YearMonth (Imagine that my dataset belong to 01/12/2021)
  • Mea: Count distinct ID  with Min(Date) aggr by ID and calcultate cumulative

So in my case Bar Chart will be:

01/2021  2  (3603 and 4076)

02/2021  3  (3603 + 4076 of 01/2021 and 4101)

03/2021  3  (3603 + 4076 of 01/2021 + 4101 of 02/2021)

04/2021  3  (3603 + 4076 of 01/2021 + 4101 of 02/2021)

05/2021  3  (3603 + 4076 of 01/2021 + 4101 of 02/2021)

...always the same to 12/2021

I've tried this  count(distinct {<DATE={"=aggr(Min(DATE),ID)"},>}ID)   but doesn't work

 

Thank you in advanced

Labels (1)
1 Reply
jwjackso
Specialist III
Specialist III

I always recommend Henric's As-Of-Table for any cumulative totals.

Using the following data:

Data:
Load * Inline [
ID,DATE
3603,01/01/2021
3603,01/02/2021
4076,01/01/2021
4076,01/03/2021
4076,01/02/2021
4101,01/02/2021
];

tmpAsOfDate:
Load Distinct [DATE]
Resident Data;
join (tmpAsOfDate)
Load [DATE] as AsOfDate
Resident tmpAsOfDate;

 

AsOfDate:
Load [DATE],
AsOfDate,
AsOfDate - [DATE] as DayDiff,
Num(Month([AsOfDate]),'00')&'/'&Year([AsOfDate]) as AsOfMonthYear;
Load [DATE],
AsOfDate
Resident tmpAsOfDate
where AsOfDate >= [DATE];

Drop Table tmpAsOfDate;

cap4.png

the Bar Chart dimension is the AsOfMonthYear

The measure is just Count(Distinct ID)