Successive IF to SUM

Zylock

New Member
Joined
Jul 8, 2022
Messages
4
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2007
Platform
  1. Windows
  2. Mobile
  3. Web
Hello! First time posting for help with excel formula. I've so far been successful at finding solutions to my relatively simple problems. This is the first task that I need help with!

What I'm trying to do is:
- Look into a cell to see if the DATE stored there is within a certain range
- THEN look into a different cell to see if the data there is one of a small list of predefined values
- THEN, if the second cell contains the right data, look into another cell to pull a number
- Finally, I want to SUM all of the successful outputs into a final, separate cell.

I'm using a spreadsheet to track pipe inspections. Each pipe is a certain length (in meters), but is only considered complete when there is an inspection done from both ends. I need to tally the total meters of each week's successfully completed pipe inspections. So far I have all of the input columns set up and correctly configured with data validation. The two columns that track if an inspection has been done from each end of the pipe have the preset values "Yes," "Needed," "Impossible," and "See Comments." For the purposes of a complete inspection, only "Yes" and "Impossible" would be considered sufficient for completion. The date column is set up to contain only dates input by the date-selection field. And there is a column containing the total number of meters for the pipe segment.

My inexperienced Excel brain has started to conceive of IF statements here and there, but I cannot even begin to see how to accomplish what I need.

Any and all help is deeply appreciated!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Welcome to the MrExcel forum!

This would be easier with SUMIFS, but I don't believe that existed in Excel 2007. So try this:

Book1
ABCDEFGH
1DATEStatusLengthStart DateEnd DateTotal Meters
27/1/2022Yes17/2/20227/13/202263
37/2/2022Needed2
47/3/2022Yes3
57/4/2022Yes4
67/5/2022Impossible5
77/6/2022See Comments6
87/7/2022Yes7
97/8/2022Impossible8
107/9/2022Needed9
117/10/2022Needed10
127/11/2022Yes11
137/12/2022Impossible12
147/13/2022Yes13
157/14/2022See Comments14
16
17
18
19
20
Sheet2
Cell Formulas
RangeFormula
H2H2=SUMPRODUCT(--(A2:A20>=E2),--(A2:A20<=F2),(B2:B20="Yes")+(B2:B20="Impossible"),C2:C20)


Adapt the formula to use your ranges.
 
Upvote 0
Whoa! Thank you. That's much more complex than I imagined, and exactly why I came here! I'll give it a shot.
 
Upvote 0
That worked perfect! How would I add a second column of "Yes," "Impossible," to the formula?
Right, I forgot to mention that I'm hosting this spreadsheet on Google Sheets if that's any help in creating a formula.
 
Upvote 0
How would I add a second column of "Yes," "Impossible," to the formula?
What do you mean? Look at a different column that has "Yes" or "Impossible" in it? Do you need a good value in both, or just one of the columns? I'm guessing that you need to check the inspection for both ends, and they both have to be ok?

Right, I forgot to mention that I'm hosting this spreadsheet on Google Sheets if that's any help in creating a formula.
In the future, please mention this in your first post. Although Excel and Google Sheets share many features, there are many differences too. I don't know Google Sheets, and I'd hate to provide a formula that won't work for you. In fact, we have a special forum called "General Questions & Other Applications" where Google Sheets questions should go.


If my assumption above is correct, then try this:

Book1
ABCDEFGHI
1DATEStatus AStatus BLengthStart DateEnd DateTotal Meters
27/1/2022YesYes17/2/20227/13/202252
37/2/2022NeededNeeded252
47/3/2022YesImpossible3
57/4/2022YesYes4
67/5/2022ImpossibleYes5
77/6/2022See CommentsSee Comments6
87/7/2022YesYes7
97/8/2022ImpossibleImpossible8
107/9/2022NeededNeeded9
117/10/2022NeededNeeded10
127/11/2022YesSee Comments11
137/12/2022ImpossibleImpossible12
147/13/2022YesYes13
157/14/2022See CommentsSee Comments14
16
17
18
19
20
Sheet2
Cell Formulas
RangeFormula
I2I2=SUMPRODUCT(--(A2:A20>=F2),--(A2:A20<=G2),((B2:B20="Yes")+(B2:B20="Impossible"))*((C2:C20="Yes")+(C2:C20="Impossible")),D2:D20)
I3I3=SUM(SUMIFS(D2:D20,A2:A20,">="&F2,A2:A20,"<="&G2,B2:B20,{"Yes","Impossible"},C2:C20,{"Yes";"Impossible"}))


If the original formula worked for you, then the I2 formula should too. I believe Google Sheets has SUMIFS, so you might try the I3 formula which is a bit shorter, but no guarantees on either one.
 
Upvote 0
Solution
What do you mean? Look at a different column that has "Yes" or "Impossible" in it? Do you need a good value in both, or just one of the columns? I'm guessing that you need to check the inspection for both ends, and they both have to be ok?

In the future, please mention this in your first post. Although Excel and Google Sheets share many features, there are many differences too. I don't know Google Sheets, and I'd hate to provide a formula that won't work for you. In fact, we have a special forum called "General Questions & Other Applications" where Google Sheets questions should go.

If the original formula worked for you, then the I2 formula should too. I believe Google Sheets has SUMIFS, so you might try the I3 formula which is a bit shorter, but no guarantees on either one.
Sorry about not mentioning use of Google Sheets. I switch back and forth between the two platforms so often, and find that everything I need to do works in both, that I forget there are meaningful differences.

I tried both formula and the first, I2, worked perfectly! Thank you so much! That solves a huge headache that would have plagued me for the next three years!
 
Upvote 0

Forum statistics

Threads
1,215,038
Messages
6,122,798
Members
449,095
Latest member
m_smith_solihull

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