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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Cumulative total based on sequence number

I need some help with a new measure or calculcated colum/table. I'm not sure how to go about doing what I need to do. This is what I have at this point for my data. Column 1 is the sequence number, 2 is the part number, 3 is the date, 4 is the quantity needed at the start of the day, 5 is the quantity that has been delivered to the department since the start of the day and then this is where I have issues.  I want the final column to show the total quantity left to be delivered for that specific sequence number. So for sequence 1, the total still needed is 36 but for sequence 6 (same part number) I want it to be a cumulative of sequence 1 and 6 so the total would be 92 and not 0. I'm not sure how to go about doing that. Another example would be sequence numbers 3 and 5, where I want 3 to show 0 needed and 5 to show we still need 36. Any help would be appreciated!!

 

 

SequenceItemDateQuantityToBuildQty DeliveredQty NeededTotal Needed for Day
1385CS15/18/2020 0:003363003692
2386CS15/18/2020 0:00450 450450
3387CS15/18/2020 0:00112300036
42249CS15/18/2020 0:00224 224224
5387CS15/18/2020 0:00224300036
6385CS15/18/2020 0:0056300092
72248CS15/18/2020 0:00224 224224
84909CS15/18/2020 0:00560 560560
94910CS15/18/2020 0:00112 112112
109441CS15/18/2020 0:0056 5656
119442CS15/18/2020 0:0056 5656
126971CS15/18/2020 0:0090 9090
136960CS15/18/2020 0:0090 9090
144797CS15/18/2020 0:0090 9090
157516CS15/18/2020 0:00300100200200
166950CS15/18/2020 0:0030 3030
176955CS15/18/2020 0:0030 3030
182647CS15/18/2020 0:003010000
3 REPLIES 3
Anonymous
Not applicable

FYI - the QTY delivered is from a different table and is being pulled in with a relationship tied to the Item. 

Maybe these two columns:

 

CumulativeQuantityToBuild = SUMX(FILTER('Table (4)',[Sequence] <= EARLIER([Sequence]) && [Item] = EARLIER([Item])),[QuantityToBuild])

Qty Needed For Sequence = 
    VAR __Needed = [CumulativeQuantityToBuild] - [Qty Delivered]
RETURN
    IF(__Needed < 0,0,__Needed)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

I cant seem to get this to work - potentially because the main table I'm working off of is a calculated table? Not sure if that matters or not.....Maybe I need to add more to my already calculated table? Here is calculation for the current table I'm using

 

Table 2 =
VAR temp =
    ADDCOLUMNS (
        'Table',
        "MinS",
        VAR s = [Sequence]
        VAR C = [Item]
        RETURN
            MINX (
                FILTER (
                    'Table',
                    VAR c1 = [Item]
                    VAR s1 = [Sequence]
                    RETURN
                        CALCULATE (
                            COUNTROWS ( 'Table' ),
                            FILTER (
                                ALL ( 'Table' ),
                                'Table'[Item] = c1
                                    && 'Table'[Sequence] <= s
                                    && 'Table'[Sequence] >= s1
                            )
                        ) = s - s1 + 1
                ),
                [Sequence]
            )
    )
RETURN
    SELECTCOLUMNS (
        SUMMARIZE (
            temp,
            [MinS],
            "Sequence", RANKX ( temp, [MinS],, ASC, DENSE ),
            "Item", MAX ( 'Table'[Item] ),
            "QuantityToBuild", SUM ( 'Table'[QuantityToBuild] ),
            "Date", MAX ( 'Table'[Date] )
        ),
        "Sequence", [Sequence],
        "Item", [Item],
        "QuantityToBuild", [QuantityToBuild],
        "Date", [Date]
    )

 Do I just need to add to this? 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors