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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
lopazopy
Frequent Visitor

Running total with dates within a separate date category

I'm trying to find a running total for orders packed within a certain PromiseDate "bucket". The dates may be in any order in my table, but the way I'm thinking they are ordered by PromiseDate in descending order and PackDate in ascending order within the PromiseDate. Looking at the records with a PromiseDate of 6/10/2023 with the expected running total will give an idea of what I'm working with.

 

Also, something else I've come across is if orders have the same pack date it groups those together, so I guess something else like OrderNum sort has to be taken into consideration. OrderNum is unique.

 

I've searched a lot and see there are many topics on this subject, but I haven't been able to get this to work (RANKX, Quick Measure - Running Total, DAX Calculate, etc). Thank you in advanced for any help or insight.

 

 

PromiseDateOrderNumPackDatePackLbsExpectedRunning
6/17/202314854/28/202310001000
6/10/202338475/2/202320003000
6/10/202341205/1/202310001000
6/10/202325875/4/202320005000
6/3/202322854/29/202310001000
6/3/202358744/29/202330004000
5/27/202356684/30/202350005000
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I assume the expected outcome is a measure, not a calculated column.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1683772086819.png

 

Expected outcome running total: =
IF (
    HASONEVALUE ( Data[PromiseDate] ),
    CALCULATE (
        SUM ( Data[PackLbs] ),
        WINDOW (
            1,
            ABS,
            0,
            REL,
            SUMMARIZE (
                ALL ( Data ),
                Data[PromiseDate],
                Data[OrderNum],
                Data[PackDate],
                Data[PackLbs]
            ),
            ORDERBY ( Data[PackDate], ASC, Data[OrderNum], ASC ),
            ,
            PARTITIONBY ( Data[PromiseDate] )
        )
    )
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I assume the expected outcome is a measure, not a calculated column.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1683772086819.png

 

Expected outcome running total: =
IF (
    HASONEVALUE ( Data[PromiseDate] ),
    CALCULATE (
        SUM ( Data[PackLbs] ),
        WINDOW (
            1,
            ABS,
            0,
            REL,
            SUMMARIZE (
                ALL ( Data ),
                Data[PromiseDate],
                Data[OrderNum],
                Data[PackDate],
                Data[PackLbs]
            ),
            ORDERBY ( Data[PackDate], ASC, Data[OrderNum], ASC ),
            ,
            PARTITIONBY ( Data[PromiseDate] )
        )
    )
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thanks so much! I had not seen the WINDOW function being used yet. I had to upgrade to the latest Desktop version of PowerBI for it to work.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors