To sum values in the rows above the current one from a different column (e.g., "Time") in an Excel table, and have that sum adapt to filtered rows only (i.e., ignore hidden/filtered-out rows), you can use a combination of:
SUBTOTAL function (to respect filtering),
- Structured references (for working with Excel tables),
- Relative references (to refer to rows above).
✅ Assumptions:
Let’s assume your table is named Table1, and it has these columns:
You want to add a new column (e.g., RunningTotal) that shows the sum of all visible "Time" values above the current row, considering any filters applied.
✅ Formula:
Place this formula in the RunningTotal column of your table:
=IF(SUBTOTAL(3, [@Index])=0, "", SUMPRODUCT(SUBTOTAL(9, OFFSET(Table1[[#Headers],[Time]], ROW( [@Time] ) - ROW(Table1[[#Headers],[Time]]), 0)), (ROW( [@Time] ) - ROW(Table1[[#Headers],[Time]]) > SEQUENCE(ROW( [@Time] ) - ROW(Table1[#Headers]), , ROW( [@Time] ) - 1, 0))))
Wait — that's complex. Let me give you a cleaner version using newer Excel functions, assuming you're on Excel 365 or 2021 (which supports dynamic arrays):
✅ Simplified Version (Recommended for Excel 365+)
In cell [@RunningTotal]:
=IF(SUBTOTAL(3, [@Index])=0, "", SUM(FILTER(Table1[[#All],[Time]], (Table1[Index] < [@Index]) * SUBTOTAL(3, OFFSET(Table1[[#Headers],[Index]], ROW(Table1[Index]) - ROW(Table1[#Headers]), 0, 1)))))
🔍 Explanation:
FILTER(...) gets the relevant rows.
(Table1[Index] < [@Index]) ensures we only include rows above the current one.
SUBTOTAL(3, ...) checks if each row is visible (not filtered out).
SUM(...) adds up the visible values above.
This will dynamically adapt to filters — it only sums visible rows above the current one.
📌 Notes:
- Replace
"Index" with whatever unique identifier you have for sorting (like a date or ID).
- If you don’t have a unique index, you may need to create one (e.g., using
=ROW() or Power Query) to ensure proper ordering.
❓Alternative (Non-Structured Table Version):
If you're not using a table, but just regular cells:
=SUMPRODUCT(SUBTOTAL(9,OFFSET($B$2,ROW(B2:INDEX(B:B,ROW()))-ROW($B$2),0))*(ROW(B2:INDEX(B:B,ROW()))<ROW()))
But again, the structured reference version is cleaner when working inside a table.
Let me know if you'd like help adapting this for your specific data!