Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Filtered Date RunningTotal

Hi,

I am using a cumulative total calculation to display a running total of a value throughout the year. The calculation is as follows:

Running Total = 
CALCULATE(SUM(Table[Amnt]),
	FILTER(
		ALLSELECTED('Date Dim'[Date]),
		'Date Dim'[Date] <= MAX('Date Dim'[Date]) 
        )
)

This works perfectly, and gives my cumulative total for my two years of data.

 

However, I want to be able to filter to Current Year, and Current Year + 1 so build the column in "Date Dim":

Year Filter = IF(YEAR('Date Dim'[Date]) == YEAR(TODAY()), "CY",
                         IF(YEAR('Date Dim'[Date]) == YEAR(TODAY())+1, "CY+1",BLANK()))
But when I filter to CY+1, the running total is still running from the current year. I want the running total to reset when filtered to CY+1 and start again from zero.
Is anyone able to help?

5 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you amitchandak , thats worked great.

    • Anonymous's avatar
      Anonymous
      Not applicable

      IanCockcroft  not that I am aware of. If I filter by anything else (lets say market), the values will change to reflect that filter

      • v-lili6-msft's avatar
        v-lili6-msft
        Icon for Community Support rankCommunity Support

        HI, Anonymous 

        You just need to adjust your formula as below:

        NEW Running Total = 
        CALCULATE(SUM('Table'[Amnt]),
        	FILTER(
        		ALLSELECTED('Date Dim'),
        		'Date Dim'[Date] <= MAX('Date Dim'[Date]) 
                )
        )

        Because for your formula, It just removes context filters from column 'Date Dim'[Date], other columns in 'Date Dim' table won't be affected.

         

        Regards,

        Lin