Running total for specific period

didijaba

Well-known Member
Joined
Nov 26, 2006
Messages
511
HI, I have formula that doesn't start calculating running total from first date of selected period but from earliest in date column.
here is code so far
Code:
RunningTotalTotalExpensesTEST = 
CALCULATE(SUM(tblOfferSaleData[TotalExpenses]),
FILTER(ALLSELECTED(tblOfferSaleData[SalesDateCalc]),
MIN('Calendar'[Date])<=tblOfferSaleData[SalesDateCalc] &&
 MAX('Calendar'[Date])>=tblOfferSaleData[SalesDateCalc]))

And this one looks properly, but doesn't adjust to date slicer
Code:
RunningTotalTotalExpenses = 
CALCULATE(SUM(tblOfferSaleData[TotalExpenses]),
FILTER(ALLSELECTED(tblOfferSaleData),
tblOfferSaleData[SalesDateCalc]<=MAX(tblOfferSaleData[SalesDateCalc])))
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Didijaba,

Using a calendar table that had no relationship with tblOfferSaleData, the following formula worked:

RunningTotalTotalExpensesTEST:=CALCULATE (
SUM ( tblOfferSaleData[Total Expenses] ),
FILTER (
tblOfferSaleData,
MIN ( 'Calendar'[Date] ) <= tblOfferSaleData[SalesDateCalc]
&& MAX ( 'Calendar'[Date] ) >= tblOfferSaleData[SalesDateCalc]
)
)

If you would like to learn more about disconnected tables in a DAX data model, please see chapters 12 and 13 in Power Pivot and Power BI by Rob Collie and Avi Singh.

Tom Allan
PowerPivotPro - Transforming your Business with Power Pivot and Power BI
 
Upvote 0
It doesn't start from first date of selected period because of the 'ALLSELECTED(tblOfferSaleData[SalesDateCalc])'. ALLSELECTED removes the top most filter applied to the 'tblOfferSaleData[SalesDateCalc]' column, which in your case may result in all the values in the table being returned. So you may want to remove the ALLSELECTED() and just go with FILTER ( VALUES ( tblOfferSaleData[SalesDateCalc] ), ... ) or FILTER ( tblOfferSaleData, ... ).
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,812
Members
449,048
Latest member
greyangel23

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