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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
bweiland
Regular Visitor

Running total for missing dates

Hello, I have data like below , how do I either create a running total column or a dax measure that will create the running total for Jan 2 equal to the Jan 1 values?  There are many 'blank' dates throughout the year not just one.

 

bweiland_0-1747614770833.png

 

2 ACCEPTED SOLUTIONS
Vijay_Chethan
Resolver III
Resolver III

Hello bweiland,
i have used a separate date table to include missing dates in sales table and set up relationship between 
date table and sales table:

Vijay_Chethan_0-1747633790550.png


Then i used the following measure to get desired running total, i also observed running total and sales are grouped by GL account

Running Total =
CALCULATE(
    SUM('Sales_Table'[sales]),
    FILTER(
        ALLSELECTED('Date_table'[Date]),
        ISONORAFTER('Date_table'[Date], MAX('Date_table'[Date]), DESC)
    )
)

Vijay_Chethan_1-1747633895462.png



if this helps, please mark as solution

View solution in original post

danextian
Super User
Super User

Hi @bweiland 

 

You can't assign a value to a row that doesn't exist in your data. If January 2 isn't present in your table, no value can be shown for it. To handle this, use a dedicated calendar table with a continuous range of dates, and make sure it's marked as a date table in your model. Set and use date tables in Power BI Desktop

danextian_1-1747633959157.png

 

Running Total = 
CALCULATE (
    SUM ( FactData[Value] ),
    FILTER (
        ALL ( CalendarTable[Date] ),
        CalendarTable[Date] <= MAX ( CalendarTable[Date] )
    )
)

danextian_0-1747633791386.png

 

Please see the attached pbix.

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

6 REPLIES 6
danextian
Super User
Super User

Hi @bweiland 

 

You can't assign a value to a row that doesn't exist in your data. If January 2 isn't present in your table, no value can be shown for it. To handle this, use a dedicated calendar table with a continuous range of dates, and make sure it's marked as a date table in your model. Set and use date tables in Power BI Desktop

danextian_1-1747633959157.png

 

Running Total = 
CALCULATE (
    SUM ( FactData[Value] ),
    FILTER (
        ALL ( CalendarTable[Date] ),
        CalendarTable[Date] <= MAX ( CalendarTable[Date] )
    )
)

danextian_0-1747633791386.png

 

Please see the attached pbix.

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Yes,this works but the below also gets the exact same results so I'm interested in what  FILTER ( ALL are required in your query?

 

Cumulative Total =

CALCULATE(

    SUM('Datatable'[Amount]),

    DATESBETWEEN(DateTable[Date], MINX(ALL(DateTable), DateTable[Date]), MAX(DateTable[Date]))

Vijay_Chethan
Resolver III
Resolver III

Hello bweiland,
i have used a separate date table to include missing dates in sales table and set up relationship between 
date table and sales table:

Vijay_Chethan_0-1747633790550.png


Then i used the following measure to get desired running total, i also observed running total and sales are grouped by GL account

Running Total =
CALCULATE(
    SUM('Sales_Table'[sales]),
    FILTER(
        ALLSELECTED('Date_table'[Date]),
        ISONORAFTER('Date_table'[Date], MAX('Date_table'[Date]), DESC)
    )
)

Vijay_Chethan_1-1747633895462.png



if this helps, please mark as solution

Yes, this works but the below gets the same result so I'm interested on what the FILTER(ALLSELECTED and ISONORAFTER functions are doing?

 

Cumulative Total =
CALCULATE(
    SUM(Data[Amount]),
    DATESBETWEEN(Data[Date], MINX(ALL(Dates),Dates[Column1]), MAX(Dates[Column1]))
pankajnamekar25
Memorable Member
Memorable Member

Hello @bweiland 

 

Use this measure

Running Total =

CALCULATE(

    SUM('SalesData'[Sales]),

    FILTER(

        ALL('SalesData'),

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

            && 'SalesData'[GL Account] = MAX('SalesData'[GL Account])

    )

)

Thanks,
 Pankaj Namekar | LinkedIn

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

This though does not does not the Jan 2 date.  Doesn't the query need to reference a data table like the below query?

bweiland_0-1747674940618.png

Cumulative Total =
CALCULATE(
    SUM(Data[Amount]),
    DATESBETWEEN(Data[Date], MINX(ALL(Dates),Dates[Column1]), MAX(Dates[Column1]))

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.