Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DonalMc
Advocate II
Advocate II

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 generate the daily difference - see my Usage column code below.

My problem is that occasionally there is a gap in the data with missing days and this gives me an erroneous number.

Any suggestions as to how to remedy?

In my head, the best way would be to fill in missing data with half the difference.

Alternatively, if there is no data, just subtract the difference from the next day where there is data.

Hopefully this makes sense! 

 

DonalMc_0-1746174476581.png

 

Usage =
var usagePreviousDay =
    CALCULATE(
            SUM('ESB Data'[Reading]),
            FILTER(
                ALL('ESB Data'),
                'ESB Data'[Date]
                 = EARLIER('ESB Data'[Date]) - 1
                 && 'ESB Data'[Type] = EARLIER('ESB Data'[Type])
                 ))
RETURN
'ESB Data'[Reading] - usagePreviousDay

 

1 ACCEPTED SOLUTION
pankajnamekar25
Super User
Super User

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.

View solution in original post

2 REPLIES 2
DonalMc
Advocate II
Advocate II

Thank you @pankajnamekar25 - that works perfectly!

pankajnamekar25
Super User
Super User

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.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.