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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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.


Go to My LinkedIn Page


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.


Go to My LinkedIn Page


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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.