Forum Discussion
richzip1
Jul 03, 2021Copper Contributor
Sum of variable number of rows
Hello, I would like to find a formula that will take the total of a column -- but the number of rows in that column will vary. The attachment hopefully helps to visualize how the totals should be gr...
- Jul 03, 2021
A formula solution that assumes data are exactly as in your sample
in F2 and copy right then down:
=IF( AND(ISNUMBER($B2),ISNUMBER($C2)), D2, IF(ISNUMBER($B2), SUM(OFFSET($D2,,COLUMNS($F:F)-1,MATCH(INT($B2), INT($C2:$C15),0))), "") )and validate it with CTRL+SHIFT+ENTER (or its equiv on Mac) if you don't run Excel 365/Web
Corresponding sample attached
Lorenzo
Jul 03, 2021Silver Contributor
A formula solution that assumes data are exactly as in your sample
in F2 and copy right then down:
=IF(
AND(ISNUMBER($B2),ISNUMBER($C2)), D2,
IF(ISNUMBER($B2), SUM(OFFSET($D2,,COLUMNS($F:F)-1,MATCH(INT($B2), INT($C2:$C15),0))), "")
)and validate it with CTRL+SHIFT+ENTER (or its equiv on Mac) if you don't run Excel 365/Web
Corresponding sample attached
richzip1
Jul 03, 2021Copper Contributor
Lorenzo Thank you so much! That worked perfectly! Could help with another formula for this same sheet - instead of taking the sum of columns, I would like to calculate the difference between the value in Column C and Column B (the first preceding row with a value in B).