Forum

Running totals - ad...
 
Notifications
Clear all

Running totals - add column

10 Posts
2 Users
0 Reactions
59 Views
(@lsimmons)
Posts: 10
Active Member
Topic starter
 

Mynda,
The solution you gave me for the running totals has been working great, but I'd like to create a version where I can add more detail.  I've attached the same example spreadsheet as before, where the top table on the "MoBal" tab works as it should, as evidenced by the "Check Column" I added on the side.  When I create the same table below, and add a column for the names, the running balance no longer works.  Can you help?

Thanks,
Luciana

 
Posted : 17/12/2019 4:51 pm
(@catalinb)
Posts: 1937
Member Admin
 

Hi Luciana,

Add ALL(Main[Depositor/Payee]) to CALCULATE context, or use the following simplified measure:

RunBal3:=IF (
COUNTROWS(Main)>0,CALCULATE (
SUM([Credits])-SUM([Debits])+SUM(AcctList[Beg Bal]),
FILTER (
ALL ( 'Calendar'[Date] ),
'Calendar'[Date]<= MAX ( 'Calendar'[Date])&&MIN ( 'Calendar'[Date] ) <= CALCULATE ( MAX ( Main[Posted Date] ), ALL ( Main) )
),ALL(Main[Depositor/Payee])),BLANK())

You will notice that there will be duplicate balances where there are duplicate dates in the dates column, mostly because there can be only 1 balance for that day, the calculations are made by date.

 
Posted : 19/12/2019 12:57 am
(@lsimmons)
Posts: 10
Active Member
Topic starter
 

Thank you Catalin,

I'm actually trying to get it to calculate a balance after each individual item, even if there are several items on the same day. I've tried adding an Index column at the beginning but that doesn't seem to be working either.  In other words, I'm trying to get the same results as what is in the "Check Column."

Thanks,
Luciana

 
Posted : 19/12/2019 12:47 pm
(@catalinb)
Posts: 1937
Member Admin
 

Hi Luciana,

When you add the index column in the Main query, make sure that the table is sorted properly by Posted Date and that detail column before adding the index, otherwise it will be messed up.

Then, use this measure to calculate the running balance:

RunBal3:=CALCULATE (
SUM(Main[Credits])-SUM(Main[Debits])+SUM(AcctList[Beg Bal]),
Filter(ALL(Main),Main[Index]<=MAX(Main[Index])&&Main[Stmt Acct #]=MAX(Main[Stmt Acct #])))

 
Posted : 21/12/2019 1:23 am
(@lsimmons)
Posts: 10
Active Member
Topic starter
 

Catalin,
The measure calculates the balances correctly but it has significantly slowed down the spreadsheet.  It is about 24000 lines, but I didn't notice the slowdown on the prior version of the measure (where it calculated by date).  Is this normal?
Thanks,
Luciana

 
Posted : 21/12/2019 5:26 pm
(@catalinb)
Posts: 1937
Member Admin
 

How slow? 1 minute, 1 hour?

 
Posted : 22/12/2019 12:57 am
(@lsimmons)
Posts: 10
Active Member
Topic starter
 

I let it run for 15 minutes before I stopped it.

 
Posted : 22/12/2019 6:13 pm
(@catalinb)
Posts: 1937
Member Admin
 

Hi Luciana,

If you use variables, is it faster?

RunBal3:=Var Acct=MAX(Main[Stmt Acct #])
Var Indx=MAX(Main[Index])
Return
CALCULATE (
SUM(Main[Credits])-SUM(Main[Debits])+SUM(AcctList[Beg Bal]),
Filter(ALL(Main),Main[Index]<=Indx&&Main[Stmt Acct #]=Acct))

 
Posted : 24/12/2019 3:40 am
(@lsimmons)
Posts: 10
Active Member
Topic starter
 

I tried that and it took about 30 minutes to complete the calculations.  Then if I changed any of the filters, it would take another 30 minutes to recalculate.  Have you ever encountered this before?

 
Posted : 27/12/2019 12:09 pm
(@catalinb)
Posts: 1937
Member Admin
 

Hi Luciana,

Don't use DAX that much for myself, did not met this problem before.
Will look into that to see if I can come up with a more efficient solution.

 
Posted : 01/01/2020 9:41 am
Share: