Sumif on Non-Continuous Range

acool

Board Regular
Joined
Feb 10, 2023
Messages
107
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I am currently trying to create a sumif formula that sums the the first twelve months where the value is NOT equal to 0 in the non-continuous range of A2:M2-O2:Z2. I have provided an example of what the outputs should look like in column AB. As mentioned the Range is non-continuous and I would like to sum the first 12 Non Zero Values in the range above.

Thank You!


1699380960760.png
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try something like this:

But not really sure what mean by non contiguous ranges and first 12 non zero values? Please clarify.

Mr Excel Questions 72.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
12024-01-012024-02-012024-03-012024-04-012024-05-012024-06-012024-07-012024-08-012024-09-012024-10-012024-11-012024-12-01TotalYear2025-01-012025-02-012025-03-012025-04-012025-05-012025-06-012025-07-012025-08-012025-09-012025-10-012025-11-012025-12-01TotalGrand Total
21010372738510172024484882361307127
333767406187020247986122104879125
acool
Cell Formulas
RangeFormula
AB2:AB3AB2=SUM(($A2:$AA2)*(--(ISNUMBER($A$1:$AA$1))))




I used my own number values, I'm not going to type all the exact information. But, the formula should work.
 
Upvote 0
Try something like this:

But not really sure what mean by non contiguous ranges and first 12 non zero values? Please clarify.

Mr Excel Questions 72.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
12024-01-012024-02-012024-03-012024-04-012024-05-012024-06-012024-07-012024-08-012024-09-012024-10-012024-11-012024-12-01TotalYear2025-01-012025-02-012025-03-012025-04-012025-05-012025-06-012025-07-012025-08-012025-09-012025-10-012025-11-012025-12-01TotalGrand Total
21010372738510172024484882361307127
333767406187020247986122104879125
acool
Cell Formulas
RangeFormula
AB2:AB3AB2=SUM(($A2:$AA2)*(--(ISNUMBER($A$1:$AA$1))))




I used my own number values, I'm not going to type all the exact information. But, the formula should work.
@awoohaw Do you know how to apply this formula to account for a scenario using a non-continuous range and sum only the first 12 non-zero numbers?
 
Upvote 0
How about
Excel Formula:
=SUM(TAKE(FILTER(A2:Z2,(A2:Z2<>0)*(COLUMN(A2:Z2)<>14)),,12))
 
Upvote 0
I think I understand what is wanted now. I think @Fluff answer may be better, but I'm not sure.

Mr Excel Questions 72.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
12024-01-012024-02-012024-03-012024-04-012024-05-012024-06-012024-07-012024-08-012024-09-012024-10-012024-11-012024-12-01TotalYear2025-01-012025-02-012025-03-012025-04-012025-05-012025-06-012025-07-012025-08-012025-09-012025-10-012025-11-012025-12-01TotalGrand Total
2101037273851017202448488236130773
33376740618702024798612210487968
acool
Cell Formulas
RangeFormula
AB2:AB3AB2=SUM(CHOOSECOLS(FILTER($A2:$AA2,(ISNUMBER($A$1:$AA$1))*($A2:$AA2<>0)),1,2,3,4,5,6,7,8,9,10,11,12))
 
Upvote 0
@awoohaw Do you know how to apply this formula to account for a scenario using a non-continuous range and sum only the first 12 non-zero numbers?

How about
Excel Formula:
=SUM(TAKE(FILTER(A2:Z2,(A2:Z2<>0)*(COLUMN(A2:Z2)<>14)),,12))

How about
Excel Formula:
=SUM(TAKE(FILTER(A2:Z2,(A2:Z2<>0)*(COLUMN(A2:Z2)<>14)),,12))
@Fluff Do you know how to apply this formula to exclude Columns M & N. The formula is currently also summing the "Total" in column M which is skewing the calculation. I would like the formula to only apply to columns where there are dates. Thank You!
 
Upvote 0
You said you wanted A2:M2 & O2:Z2, if you dont want col M then use
Excel Formula:
=SUM(TAKE(FILTER(A2:Z2,(A2:Z2<>0)*(COLUMN(A2:Z2)<>14)*(COLUMN(A2:Z2)<>13)),,12))
 
Upvote 0
Solution
You said you wanted A2:M2 & O2:Z2, if you dont want col M then use
Excel Formula:
=SUM(TAKE(FILTER(A2:Z2,(A2:Z2<>0)*(COLUMN(A2:Z2)<>14)*(COLUMN(A2:Z2)<>13)),,12))
This did the trick. Thank you both for your help!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
This did the trick. Thank you both for your help!
@Fluff Just curious: When trying this formula on another sheet, it is providing me with the incorrect totals despite applying the same logic of the formula. If I am using the formula that you provided above to sumif cells that have utilize other formula to get to a total, could that mess up the calculation?
 
Upvote 0

Forum statistics

Threads
1,215,140
Messages
6,123,270
Members
449,093
Latest member
Vincent Khandagale

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