Sum of First 12 Non-Zero Values + If less than 12 Sum of Total

GP24

New Member
Joined
Nov 23, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi - I am trying to sum the first 12 Values in a set that aren't Zero. I found a great formula from @ Dr. Steele that works great, but the problem I have is that some of my rows have less than 12 non-zero values, so for those I would like the values from the first non-zero for the next 11 rows (12 total). Below is the formula I found. I did also have to add <>0 as there is a negative task amount I wanted the formula to work on. Any ideas?


=SUM(D1:INDEX(D1:AY1,1,SMALL(IF(D1:AY1>0,COLUMN(D:AY)-COLUMN(D:D)+1),B2)))when invoked with CtrlShiftEnter and B2=12
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Try this one
Excel Formula:
=SUM(IFERROR(INDEX(1:1,AGGREGATE(15,6,COLUMN(D1:AY1)/(D1:AY1>0),SEQUENCE(,12))),0))
 
Upvote 0
Solution
Try this one
Excel Formula:
=SUM(IFERROR(INDEX(1:1,AGGREGATE(15,6,COLUMN(D1:AY1)/(D1:AY1>0),SEQUENCE(,12))),0))
Thank you! This seems to work well, except in the scenario where the values are a negative number, is there a way to account for that?
 
Upvote 0
Thank you! This seems to work well, except in the scenario where the values are a negative number, is there a way to account for that?
Found it - sorry I overlooked that part of the formula. That works perfectly thank you.

For reference this is what I used.

=SUM(IFERROR(INDEX(197:197,AGGREGATE(15,6,COLUMN(X197:AU197)/(X197:AU197<>0),SEQUENCE(,12))),0))
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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