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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Manjarigoyal1
Frequent Visitor

How to substract current row with next row and then substract the result to next row?

I am trying to substarct the row1 to row2 and then the result will be substracted from row 3 and so on. I am looking for M Query NOT in DAX. Below is the sample data with expected result. Thanks for the help.

Delivery WeekTotal DeliveryExpected Result
31-Dec-232542525425
6-Jan9225333
13-Jan17225161
20-Jan12225039
27-Jan11224927
3-Feb21824709
10-Feb16024549
17-Feb15424395
24-Feb13524260
2-Mar18024080
9-Mar18423896
16-Mar15123745
23-Mar18323562
30-Mar18223380
6-Apr17123209
13-Apr18023029
20-Apr14022889
27-Apr2122868
2 ACCEPTED SOLUTIONS
AlienSx
Super User
Super User

there are so many running total solutions out there... 

let
    lst = List.Buffer(Table.ToRows(your_table)),
    res = Table.FromList(
        List.Generate(
            () => [i = 0, c = lst{0},  s = c{1}],
            (x) => x[i] < List.Count(lst),
            (x) => [i = x[i] + 1, c = lst{i}, s = x[s] - c{1}],
            (x) => x[c] & {x[s]}
        ),
        (x) => x, 
        {"week", "delivery", "expected"}
    )
in
    res

View solution in original post

nazaretalaragon
Regular Visitor

Hi, I recommend you check out a cool site that helps with writing a package handler resume https://resumegets.com/package-handler, ResumeGets offers specialized guidance designed specifically for those in the transportation and logistics industry, making it the perfect resource for package handlers. They provide comprehensive examples and templates designed to emphasize key competencies required for the role, such as workflow planning and the ability to multitask. I would definitely recommend this site to you.

View solution in original post

2 REPLIES 2
nazaretalaragon
Regular Visitor

Hi, I recommend you check out a cool site that helps with writing a package handler resume https://resumegets.com/package-handler, ResumeGets offers specialized guidance designed specifically for those in the transportation and logistics industry, making it the perfect resource for package handlers. They provide comprehensive examples and templates designed to emphasize key competencies required for the role, such as workflow planning and the ability to multitask. I would definitely recommend this site to you.

AlienSx
Super User
Super User

there are so many running total solutions out there... 

let
    lst = List.Buffer(Table.ToRows(your_table)),
    res = Table.FromList(
        List.Generate(
            () => [i = 0, c = lst{0},  s = c{1}],
            (x) => x[i] < List.Count(lst),
            (x) => [i = x[i] + 1, c = lst{i}, s = x[s] - c{1}],
            (x) => x[c] & {x[s]}
        ),
        (x) => x, 
        {"week", "delivery", "expected"}
    )
in
    res

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
Top Kudoed Authors