Forum Discussion

MH3's avatar
MH3
Icon for Helper V rankHelper V
5 years ago
Solved

Cumulative Sum Not Working on Year

Hello,

 

I have Car sales per month each year. from 2007 till 2020.

 

the Fiscal year starts from July to June

 

I have to caluclate the cumulative sum of each year  but the formula seems to be not working.

 

Visualization:



Cumulative Sales - Measure :

 

Cumlative Sales = 
VAR LastVisibleDate =
    MAX ( 'Date'[Date] )
VAR FirstVisibleDate =
    MIN ( 'Date'[Date] )
VAR LastDateWithSales =
    CALCULATE (
        MAX ( Sales[Date] ),
        REMOVEFILTERS ()   -- Use ALL ( Sales ) if REMOVEFILTERS () and ALL () 
                           -- are not available
    )
VAR Result =
    IF (
        FirstVisibleDate <= LastDateWithSales,
        CALCULATE (
           [Units Sold],
            'Date'[Date] <= LastVisibleDate 
        )
    )
RETURN
    Result

 



But the measure is jsut calculating the cumulative sum all over, neglecting the different year.

 

Any Help?

2 Replies