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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Badzreyes00
Contributor III
Contributor III

Cumulative Count on Pivot table that Ignores other Date

Hi Everyone,

I have a requirement that I really hope you can help me with since I find it very complex for me.

In my current data model, I am using a Date Bridge and one of date reference is "Open_Account_Date" or "OPENACCT" so I am using this date reference for my Pivot Table. 

Below is my formula for Cumulative Open Account Count

RangeSum(Before(count({$<DateBasis={"OPENACCT"},Account_Status={'OPEN'}, DateNum={"<=$(=Max(DateNum))"}, Year=, Month=, Week=, Day=, Date= >}distinct Account_No), 0, ColumnNo()))

In my current output I am already not counting those with CLOSE account status even though they are still Open on those Month. Kindly see below sample data.

Sample Account Table:

Person_NoAccount_NoAccount_TypeOpen_Account_DateAccount_StatusClose_Date
1000121111ACT02Jan-2020OPENNULL
1000221112ACT01Jan-2020CLOSEMay-2020
1000221113ACT02Jan-2020OPENNULL
1000323824ACT01Jan-2020CLOSEMay-2020
1000423876ACT01Feb-2020OPENNULL
1000433218ACT02March-2020OPENNULL
1000498812ACT03April-2020CLOSEJune-2020
1000598816ACT03Feb-2020OPENNULL
1000527584ACT02April-2020OPENNULL
1000657482ACT01March-2020OPENNULL
1000719284ACT02April-2020OPENNULL
1000817885ACT01March-2020OPENNULL
1000919960ACT02Feb-2020CLOSEMarch-2020
1000917741ACT03March-2020OPENNULL
1000919573ACT01April-2020OPENNULL
1001094717ACT02April-2020CLOSEMay-2020
1001043814ACT03Feb-2020OPENNULL
1001148319ACT01April-2020CLOSEJune-2020
1001176598ACT03May-2020OPENNULL
1001277526ACT02Jan-2020CLOSEFeb-2020
1001255632ACT03May-2020OPENNULL

 

Current Output - Cumulative Open Account Count

Open Count     
Account TypeJan-20Feb-20Mar-20Apr-20May-20
ACT0101344
ACT0222355
ACT0302335

 

Expected Output - Cumulative Open Account Count

Open Count     
Account TypeJan-20Feb-20Mar-20Apr-20May-20
ACT0123575
ACT0233366
ACT0302346

 

I will really appreciate any input please. Thank you so much in advance!

Labels (3)
1 Reply
sunny_talwar
MVP
MVP

@Badzreyes00 try something like this instead

Table:
LOAD Person_No,
	 Account_No,
	 Account_Type,
	 Date#(Open_Account_Date, 'MMM-YY') as Open_Account_Date,
	 Account_Status,
	 Alt(Date#(Close_Date, 'MMM-YY'), MonthStart(Today())) as Close_Date;
LOAD * INLINE [
    Person_No, Account_No, Account_Type, Open_Account_Date, Account_Status, Close_Date
    10001, 21111, ACT02, Jan-20, OPEN, NULL
    10002, 21112, ACT01, Jan-20, CLOSE, May-20
    10002, 21113, ACT02, Jan-20, OPEN, NULL
    10003, 23824, ACT01, Jan-20, CLOSE, May-20
    10004, 23876, ACT01, Feb-20, OPEN, NULL
    10004, 33218, ACT02, Mar-20, OPEN, NULL
    10004, 98812, ACT03, Apr-20, CLOSE, Jun-20
    10005, 98816, ACT03, Feb-20, OPEN, NULL
    10005, 27584, ACT02, Apr-20, OPEN, NULL
    10006, 57482, ACT01, Mar-20, OPEN, NULL
    10007, 19284, ACT02, Apr-20, OPEN, NULL
    10008, 17885, ACT01, Mar-20, OPEN, NULL
    10009, 19960, ACT02, Feb-20, CLOSE, Mar-20
    10009, 17741, ACT03, Mar-20, OPEN, NULL
    10009, 19573, ACT01, Apr-20, OPEN, NULL
    10010, 94717, ACT02, Apr-20, CLOSE, May-20
    10010, 43814, ACT03, Feb-20, OPEN, NULL
    10011, 48319, ACT01, Apr-20, CLOSE, Jun-20
    10011, 76598, ACT03, May-20, OPEN, NULL
    10012, 77526, ACT02, Jan-20, CLOSE, Feb-20
    10012, 55632, ACT03, May-20, OPEN, NULL
];

Dates:
LOAD Account_No,
	 Date(MonthStart(Open_Account_Date, IterNo()-1), 'MMM-YY') as Date
Resident Table
While MonthStart(Open_Account_Date, IterNo()-1) <= Close_Date;

One you do this, all you would need is two dimensions (Account_Type and Date) and Count(DISTINCT Account_No) as your expression