Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Addition of balances for accounts only during month they were opened

Process DateAccount NumberBalanceOpen Date
01/31/2014XX1$501/05/2014
01/31/2014XX2$1001/12/2014
01/31/2014XX3$501/28/2014
02/28/2014XX1$1001/05/2014
02/28/2014XX2$501/12/2014
02/28/2014XX4$1002/12/2014
03/31/2014XX1$501/05/2014
03/31/2014XX2$1001/12/2014
03/31/2014XX5$503/15/2014
04/30/2014XX1$1001/05/2014
04/30/2014XX6$504/14/2014
04/30/2014XX7$1004/30/2014
05/31/2014XX1$501/05/2014
05/31/2014XX6$1004/14/2014
05/31/2014XX7$504/30/2014

I have the data shown above and I am trying to create a graph that will show me how many accounts were opened in a month and what was the closing balance for those accounts during the month they were opened. I am having problems with the addition of the balances, since it is duplicating the balance for the accounts during different months they are active and not just the balance for the month when the account was opened.

My dimension for my graph is open month and I would like it to show:

Month# Accounts OpenedBalances for those Accounts During Opening month
January3$20
February1$10
March1$5
April2$15
May0$0

I have tried many formulas but haven't gotten the right one for the balance. Thank you for the help.

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

USE BELOW SCRIPT

==========================================

Test:

Load *, Month([Process Date]) as PDMonth, Month([Open Date]) as ODMonth;

Load

  Date(Date#([Process Date],'MM/DD/YYYY')) as [Process Date],

  [Account Number],

  Balance,

  Date(Date#([Open Date],'MM/DD/YYYY')) as [Open Date]

Inline

[

  Process Date, Account Number, Balance, Open Date

  01/31/2014, XX1, 5, 01/05/2014

  01/31/2014, XX2, 10, 01/12/2014

  01/31/2014, XX3, 5, 01/28/2014

  02/28/2014, XX1, 10, 01/05/2014

  02/28/2014, XX2, 5, 01/12/2014

  02/28/2014, XX4, 10, 02/12/2014

  03/31/2014, XX1, 5, 01/05/2014

  03/31/2014, XX2, 10, 01/12/2014

  03/31/2014, XX5, 5, 03/15/2014

  04/30/2014, XX1, 10, 01/05/2014

  04/30/2014, XX6, 5, 04/14/2014

  04/30/2014, XX7, 10, 04/30/2014

  05/31/2014, XX1, 5, 01/05/2014

  05/31/2014, XX6, 10, 04/14/2014

  05/31/2014, XX7, 5, 04/30/2014

];

==================================

Now create a Straight Table

Dimension

PDMonth

Expression

1) COUNT(Distinct IF(PDMonth = ODMonth, [Account Number]))

2) SUM(Distinct IF(PDMonth = ODMonth, Balance))

View solution in original post

3 Replies
MK_QSL
MVP
MVP

USE BELOW SCRIPT

==========================================

Test:

Load *, Month([Process Date]) as PDMonth, Month([Open Date]) as ODMonth;

Load

  Date(Date#([Process Date],'MM/DD/YYYY')) as [Process Date],

  [Account Number],

  Balance,

  Date(Date#([Open Date],'MM/DD/YYYY')) as [Open Date]

Inline

[

  Process Date, Account Number, Balance, Open Date

  01/31/2014, XX1, 5, 01/05/2014

  01/31/2014, XX2, 10, 01/12/2014

  01/31/2014, XX3, 5, 01/28/2014

  02/28/2014, XX1, 10, 01/05/2014

  02/28/2014, XX2, 5, 01/12/2014

  02/28/2014, XX4, 10, 02/12/2014

  03/31/2014, XX1, 5, 01/05/2014

  03/31/2014, XX2, 10, 01/12/2014

  03/31/2014, XX5, 5, 03/15/2014

  04/30/2014, XX1, 10, 01/05/2014

  04/30/2014, XX6, 5, 04/14/2014

  04/30/2014, XX7, 10, 04/30/2014

  05/31/2014, XX1, 5, 01/05/2014

  05/31/2014, XX6, 10, 04/14/2014

  05/31/2014, XX7, 5, 04/30/2014

];

==================================

Now create a Straight Table

Dimension

PDMonth

Expression

1) COUNT(Distinct IF(PDMonth = ODMonth, [Account Number]))

2) SUM(Distinct IF(PDMonth = ODMonth, Balance))

Not applicable
Author

Perfect! Thank you so much.. worked like a charm

MK_QSL
MVP
MVP

Kindly close the thread by selecting correct answer so that others can also use it..