Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowTry your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now
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 Week | Total Delivery | Expected Result |
| 31-Dec-23 | 25425 | 25425 |
| 6-Jan | 92 | 25333 |
| 13-Jan | 172 | 25161 |
| 20-Jan | 122 | 25039 |
| 27-Jan | 112 | 24927 |
| 3-Feb | 218 | 24709 |
| 10-Feb | 160 | 24549 |
| 17-Feb | 154 | 24395 |
| 24-Feb | 135 | 24260 |
| 2-Mar | 180 | 24080 |
| 9-Mar | 184 | 23896 |
| 16-Mar | 151 | 23745 |
| 23-Mar | 183 | 23562 |
| 30-Mar | 182 | 23380 |
| 6-Apr | 171 | 23209 |
| 13-Apr | 180 | 23029 |
| 20-Apr | 140 | 22889 |
| 27-Apr | 21 | 22868 |
Solved! Go to Solution.
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
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
Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.
Check out the May 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 1 |
| User | Count |
|---|---|
| 11 | |
| 10 | |
| 5 | |
| 4 | |
| 4 |