Cumulative Total Not Working

pjmorris

Well-known Member
Joined
Aug 2, 2012
Messages
2,172
Office Version
  1. 365
Platform
  1. Windows
Hi, this should be very simple, but I can't work it out. I'm trying to create a cumulative balance from a simple income and expenditure sheet filtered by date using a qryCalendar in PowerPivot.

I have the following measures:
1. [Credits]=sum(qryTransactions[Credit])
2. [Debits]=sum(qryTransactions[Debit])
3. [earliest]=min(qryCalendar[Date])
4. [latest]=max(qryCalendar[Date])
5. [balance]=[Credits]-[Debits]
and
6. [CumBal]=CALCULATE([Credits]-[Debits],
ALLSELECTED(qryCalendar),
FILTER(qryCalendar,qryCalendar[Date]<=[latest]))

The calendar is linked to the transaction table in PowerPivot.

If I delete the Filter clause from the [CumBal] measure it successfully calculates the cumulative balance across the entire date range. My logic is then that applying the Filter Clause should exclude all more recent transactions and therefore deliver a cumulative result. The first table below shows what happens without the FILTER clause '[CumBal]=CALCULATE([Credits]-[Debits], ALLSELECTED(qryCalendar))', (rows 7 & 14 are the problem measure):

1st Lifton Scouts Accounts - 2021 - New Version.xlsm
ABC
1Calendar
2Row Labels20162017
3Beavers
4Credits£2,142.50£2,754.50
5Debits£955.99£1,396.85
6Balance£1,186.51£1,357.65
7CumBal£2,544.16£2,544.16
8earliest05 Apr 1605 Apr 17
9latest04 Apr 1704 Apr 18
10Cubs
11Credits£2,820.26£2,558.15
12Debits£1,275.44£1,355.05
13Balance£1,544.82£1,203.10
14CumBal£2,747.92£2,747.92
15earliest05 Apr 1605 Apr 17
16latest04 Apr 1704 Apr 18
Sheet1


and the second is the result with the measure as shown at 6. What I should be getting in cells c7 and c14 is £2544.16 and £2747.92 respectively. It appears to be fully filtering by date, but I expected the ALLSELECTED(qryCalendar) to resolve that. I've even tried changing to FILTER(ALLSELECTED(qryCalendar),qryCalendar[Date]<=[latest]) but that then ignores the [latest] date. I've tried disconnecting the tables and that didn't work either.

1st Lifton Scouts Accounts - 2021 - New Version.xlsm
ABC
1Calendar
2Row Labels20162017
3Beavers
4Credits£2,142.50£2,754.50
5Debits£955.99£1,396.85
6Balance£1,186.51£1,357.65
7CumBal£1,186.51£1,357.65
8earliest05 Apr 1605 Apr 17
9latest04 Apr 1704 Apr 18
10Cubs
11Credits£2,820.26£2,558.15
12Debits£1,275.44£1,355.05
13Balance£1,544.82£1,203.10
14CumBal£1,544.82£1,203.10
15earliest05 Apr 1605 Apr 17
16latest04 Apr 1704 Apr 18
Sheet1


I simply can't see what is probably right before my eyes and any suggestions will be gratefully received.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top