Running Total Calculation

Hi Everyone!
I am working on a BAQ to populate a Pareto chart showing scrap reasons. The BAQ lists the number of times a part is scrapped for various reasons. I would like to add a running total to the BAQ. My attempts keep coming up short. In the attached example, the category count is the column I want to sum. The RunningTotal column should show a total as it increases for each line. Instead it shows the total as it increases in each change in CatCount. So at the end, where there are multiple categories with just 1 in each, the running total only counts all the 1s together. So the running total seems correct until it hits a group of CatCounts with the same number. Here is a small chart showing what my BAQ is outputting.

"Description"	CatCount	RunningTotal	
"Stock On / Stock Off"	7	7
"I.D. Size"	5	12
"Thread"	4	16
"O.D. Size"	3	19
"Surface Defect (scratch, dent)"	2	21
"Location"	1	23
"Missing Dimension"	1	23

At then end, the last two rows should have 22 and 23, instead of 23 in both.
What am I missing here?
Note: BAQ uses op 900 as last inspection op. Filtering on ReasonCode = S, with some positive scrap quantity in labor.
Thanks!
Nate
QCPassFail.baq (60.2 KB)

I had to use this expression for my running total. I had never used “Rows Unbounded Preceding” before, but it does the trick here!

sum(SubQuery3.Calculated_CatCount) over (order by SubQuery3.Calculated_CatCount desc ROWS UNBOUNDED PRECEDING)
3 Likes