Forum Discussion

Linnox's avatar
Linnox
Regular Visitor
1 year ago
Solved

Rolling total Not Working Correctly

hi, I have this calculation for the same day sales. the result is correct. 

Sales R3M Same Day =
VAR _currentdate =
    MAX ( DateTable[Date])
VAR _day =
    DAY ( _currentdate )
VAR _previousmonthenddate =
    EOMONTH ( _currentdate, -1 )
VAR _twomonthsbeforeenddate =
    EOMONTH ( _currentdate, -2 )
VAR _threemonthsbeforeenddate =
    EOMONTH ( _currentdate, -3 )
RETURN
    CALCULATE (
        SUM ( Sales[Invoices] ),
        DAY ( DateTable[Date] ) = _day,
        EOMONTH (DateTable[Date], 0 ) = _previousmonthenddate
            || EOMONTH (DateTable[Date], 0 ) = _twomonthsbeforeenddate
            || EOMONTH ( DateTable[Date], 0 ) = _threemonthsbeforeenddate
    )
 
Now, i need to create a rolling total for the month out of the Sales R3M Same Day output. 
I created a quick measure:
Sales R3M Same Day running total in Date =
CALCULATE(
    [Sales R3M Same Day],
    FILTER(
        ALLSELECTED('DateTable'),
        'DateTable'[Date] <= MAX('DateTable'[Date])
    )
)
 
But the output of this rolling total is giving me the same result as that of the Sales R3M Same Day. 
Can you help correct the Rolling total calc?
  • Sumx(

    FILTER(

    ALLSELECTED('DateTable'[Year Month]),

    'DateTable'[Date] <= MAX('DateTable'[Date])

    ),

    [Sales R3M Same Day]

    )

     

    Something like this, calculate the measure per year month and sum the values.

     

2 Replies

  • Deku's avatar
    Deku
    Super User

    Sumx(

    FILTER(

    ALLSELECTED('DateTable'[Year Month]),

    'DateTable'[Date] <= MAX('DateTable'[Date])

    ),

    [Sales R3M Same Day]

    )

     

    Something like this, calculate the measure per year month and sum the values.

     

  • Linnox Try using

    DAX
    Sales R3M Same Day running total in Date =
    CALCULATE(
    [Sales R3M Same Day],
    DATESINPERIOD(
    'DateTable'[Date],
    LASTDATE('DateTable'[Date]),
    -1,
    MONTH
    )
    )