Customized running total in Excel power query

sara1312

New Member
Joined
Sep 9, 2024
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Please find the attached table

GroupSKUSHours of production runTarget hoursIndexRunning TotalExample Colum
Group 11233612323
Group 124362274
Group 133363303
Group 1410364406
Group 152336563Not Eligible
Group 161336676Not Eligible
Group 171636792Not Eligible
Group 1831368123Not Eligible
Group 1913369136Not Eligible
Group 110153610151Not Eligible
Group 111233611174Not Eligible
Group 112723612246Not Eligible
Group 113113613257Not Eligible
Group 11453614262Not Eligible
Group 115623615324Not Eligible
Group 116203616344Not Eligible
Group 117643617408Not Eligible
Group 2182236182222
Group 2191036193210
Group 2208336201154
Group 221243621139Not Eligible
Group 222653622204Not Eligible
Group 223103623214Not Eligible

Group 1 hours of production run to be running totaled but when its above 36 hours return the hours to add up to 36 , the remaining skus are not eligible for the calculation

Kindly support on how we can achieve this
 
Can you post your query?
Hi , I used the below
The issue is when change to the new source , this custom step is not capturing the data. It stay with the initial file.
The new source table name is also "SCHEDULE" FYI.
I created a blank query to map the previous as a work around , but I would like to have the source fetched from the previous step or I need a solution to overcome this

= let
Source = Excel.CurrentWorkbook(){[Name="SCHEDULE"]}[Content],
Group = Table.Group(Source, {"GPRS Code"}, {{"All", each
let tbl = Table.RemoveColumns(_, {"Threshold"}),
tbl1= Table.AddIndexColumn(_, "idx"),
tbl2= Table.AddColumn(tbl, "Threshold", each
if [RT] <= 36 then [Hours] else
if [idx] = 0 then 36 else
if tbl[RT]{[idx] -1} < 36 then 36 - tbl[RT]{[idx] -1} else
"Not Eligble"
)
in
tbl1
}}),
Result = Table.RemoveColumns(Table.Combine(Group[All]), {"idx"})
in
Result
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
So if have a query already like below ending with StepN (change to whatever your last step is named) then have my code reference that last step

Power Query:
let
    Source = ...
    Step1 = ...
    Step2 = ...
    ...
    StepN = ...
    Group = Table.Group(StepN, {"GPRS Code"}, {{"All", each
        let tbl = Table.RemoveColumns(_, {"Threshold"}),
            tbl1= Table.AddIndexColumn(_, "idx"),
            tbl2= Table.AddColumn(tbl, "Threshold", each
                if [RT] <= 36 then [Hours] else
                if [idx] = 0 then 36 else
                if tbl[RT]{[idx] -1} < 36 then 36 - tbl[RT]{[idx] -1} else
                "Not Eligble")
        in
            tbl2
    }}),
    Result = Table.RemoveColumns(Table.Combine(Group[All]), {"idx"})
in
    Result
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,148
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top