Forum Discussion

arhomberg's avatar
arhomberg
Icon for Helper I rankHelper I
5 years ago
Solved

Find a rolling sum for a specific moment in time while checking for most recent entry

Hello everyone,   I posted not too long ago about working to find the rolling sum with a snapshot in time within Power BI DAX.   Article: Solved: Re: Find a rolling sum for a specific moment in t...
  • AlexisOlson's avatar
    AlexisOlson
    5 years ago

    So you aren't looking for the most recent but the most recent up to a particular (dynamically determined) date? In that case, a calculated column is indeed not flexible enough but you can adapt similar logic.

     

    If you want to take the rows with the last modification up to LastVisibleDate, then you can combine the expressions above into something like this:

    [Total MRR] =
    VAR LastVisibleDate = MAX ( Dates[Date] )
    RETURN
        SUMX (
            FILTER (
                T,
                T[System Mod Stamp]
                    = CALCULATE (
                        MAX ( T[System Mod Stamp] ),
                        FILTER (
                            ALLEXCEPT ( T, T[Transaction No. (ID)] ),
                            T[System Mod Stamp] <= LastVisibleDate
                        )
                    )
                    && T[Start Date] <= LastVisibleDate
                    && LastVisibleDate <= T[End Date]
            ),
            T[MRR Amount]
        )