Forum Discussion

DonalMc's avatar
DonalMc
Advocate II
1 year ago
Solved

Cumaltive Diff with missing days

I have an auto-generated dataset with a cumalative number. I used the method from v-ljerr-msft in Solved: Day to day difference in cumulative values DAX or ... - Microsoft Fabric Community to generat...
  • pankajnamekar25's avatar
    1 year ago

    Hello DonalMc 

     

    try thid DAX code

    Usage =

    VAR currentDate = 'ESB Data'[Date]

    VAR currentType = 'ESB Data'[Type]

     

    VAR previousDate =

        CALCULATE(

            MAX('ESB Data'[Date]),

            FILTER(

                ALL('ESB Data'),

                'ESB Data'[Date] < currentDate &&

                'ESB Data'[Type] = currentType

            )

        )

     

    VAR previousReading =

        CALCULATE(

            SUM('ESB Data'[Reading]),

            FILTER(

                ALL('ESB Data'),

                'ESB Data'[Date] = previousDate &&

                'ESB Data'[Type] = currentType

            )

        )

     

    RETURN

        IF(

            NOT ISBLANK(previousReading),

            'ESB Data'[Reading] - previousReading,

            BLANK()

        )

    Thanks,
     Pankaj Namekar | LinkedIn

    If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.