I used the COUNTIFS formula and received the same result despite using different criteria. Below is a simplified scenario and here's a screenshot (sorry, newbies cannot post image).
Col A | Col B | Col C | Col D | Col E | Col F |
8/31/12 | Yes | Step 1 | 0 | 8/31/12 | blank | 8/31/12
8/31/12 | blank | blank | 10,000 |
8/31/12 | No | Step 5 | 0 |
The intended logic is as follows:
Criteria 1: include if column A matches "8/31/12" or cell F2
Criteria 2: include if column B is "Yes" or blank
Criteria 3: include if column C matches "Step 1"
Criteria 4: include if column D equals "0"
Here's are the two formulas that both resulted in the same answer (count = 1):
=COUNTIFS(A2:A4,F2,B2:B4,"Yes",C2:C4,"Step 1",D2:D4,0
=COUNTIFS(A2:A4,F2,B2:B4,"<>",C2:C4,"Step 1",D2:D4,0
Also, any suggestions on tweaking the formula to SUM column D if criteria 1-3 are met? Should I use SUMIFS? I think so but the argument structure is different.
Thanks!
=COUNTIFS(A2:A4,F2,B2:B4,"<>",C2:C4,"Step 1",D2:D4,0
should be
=COUNTIFS(A2:A4,F2,B2:B4,"",C2:C4,"Step 1",D2:D4,0
as "" will count blanks, not "<>" for CountIfs / SumIfs
SUMIFS would be
=SUMIFS(D2:D4,A2:A4,F2,B2:B4,"",C2:C4,"Step 1")
Related
So I have an example below of what I'm wanting to do.
Basically I need to Index Column B from Sheet 1 into Sheet 2 BUT ONLY if the values in Column W in Sheet 1 are greater than 0. If it's not then I don't want it to be included in. The only column to Index is B starting from row 5 to say 100. Same for Column W.
I was trying to do it myself as I found This which is very similar as what I'm wanting to do but I couldn't figure it out.
Sheet 1
Row# Column B | Column(s)… | Column W
=================================
5) Thing 1 | | 0
6) Thing 2 | | 3
7) Thing 3 | | 0
8) Thing 4 | | 1
Sheet 2
Row# Column B | Column C | Column D
=================================
5) Thing 2 | 3 |
6) Thing 4 | 1 |
7) | |
8) | |
EDIT #3
You can use either SMALL, LARGE function to return the values from Column B on your Sheet1.
Presume you have given the following names:
Sheet1ColB: Sheet1!B5:B100
Sheet1ColW: Sheet1!W5:W100
Here is the formula to be put in Cell B5 on your Sheet2. Please note it is an array formula so you need to press Ctrl+Shift+Enter to confirm.
{=IFERROR(INDEX(Sheet1ColB,SMALL(IF((Sheet1ColW>0)*(LEN(Sheet1ColW)>0),ROW(Sheet1ColW)),ROW()-4)-4),"")}
or
{=IFERROR(INDEX(Sheet1ColB,LARGE(IF((Sheet1ColW>0)*(LEN(Sheet1ColW)>0),ROW(Sheet1ColW)),ROW()-4)-4),"")}
You can then use INDEX+MATCH to return the value from Column W on your Sheet1 in Column C on your Sheet2:
=IFERROR(INDEX(Sheet1ColW,MATCH(B5,Sheet1ColB,0)),"")
In the above screen-shot Solution 2 is using AGGREGATE which follows the same logic as SMALL/LARGE.
As you can see the sample data has taken into account duplicated values in Sheet 1 Col W, blank cells in both Column W and Column B on Sheet1, and blank cells, negative value or 0 value in Column B only on Sheet1.
Cheers :)
Use AGGREGATE() formula to filter based on condition.
=IFERROR(INDEX($A$5:$A$8,AGGREGATE(15,6,(ROW($A$5:$A$8)-ROW($A$4))/($B$5:$B$8>0),ROW(1:1))),"")
I have a spreadsheet that looks like this:
A B C D
------------------------------------
1 | Yes | No | | | |
2 | 1 | 1 | 0 | 1 | 0 |
------------------------------------
------------------------------------
12| Yes | No | | Yes | Yes |
13| Yes | Yes | No | No | |
14| Yes | No | | No | Yes |
15| No | Yes | No | No | |
...
I want to fill the cells in Row 2 with a 1 or 0 depending on several criteria. The value should be 1 if all of the following are met (using cell D2 as a reference):
All previous values in Row 1 should match at least one entry in the table starting at D12. For cell D2, this means A1:C1 should exactly match columns A:C in at least one row of the table.
For any of the matching rows from #1, there should be a non-empty value in the same column as the cell being evaluated. So cell D2 would look for a non-empty value in Column D of any rows that match the criteria in #1.
If either of these conditions fails, the cell value should be 0. In Cell D2 we have a value of 1 because the algorithm finds a match in rows 12 and 14 and a non-empty cell in D12 and D14.
I'll need to be able to apply this dynamically across several columns so I'm trying to avoid writing a column-specific function. I realize I could probably write a UDF to perform this, but I wanted to avoid going that route if possible.
Because this was a challenge I had a go at it and came up with
=SIGN(SUM(--(MMULT(($A1:A1=$A12:A15)*(B12:B15<>""),TRANSPOSE(COLUMN($A12:A15)^0))=COLUMNS($A1:A1))))
to be entered in B2 and pulled across. This has to be entered as an array formula using CtrlShiftEnter
A2 I think is just
=sign(counta(a12:a15))
because it will be 1 unless the whole column is empty.
I'm not sure there's a complete answer to your problem as stated without a UDF, but I'd question the method a bit and say "why complicate with 'AND this column isn't blank (but could be any other value)?"
Why not just look for a row match from that field backward? Seems to me it would just shift things by a column, and in fact, this is exactly what you're doing in A2 anyway, since there's nothing before A. So matching on duplicate rows for example, D2 would contain basically the same information as your example has in C2.
To look for duplicates across fields, you could use something like this formula that would go in C2: =IF(SUMPRODUCT((A3:A15=A1)*1,(B3:B15=B1)*1,(C3:C15=C1)*1)>1,1,0)
In D2, you'd copy that formula and add (D3:D15=D1)*1, etc.
For example: I have two sheets, both with matching columns, Column A and B are the same on both sheet. Column A on both sheets will always match, they will always contain the same value, but Column B may be different, like in the example bellow. All of the data matches besides row 3. In Sheet 1 it has "c" in column B, but in Sheet 2 it has "f" in column B.
What I am trying to do is have a column that shows if they match or not, so in the example, row 1, 2 and 4 would all have "match", but row 3 it would say "mismatch" and I am trying to have this all on a separate sheet (sheet 3).
I think Vlookup would be the best bet, but I have no idea where to start. Any help would be appreciated.
Sheet 1:
ColumnA | ColumnB
1 | a
2 | b
3 | c
4 | d
Sheet 2:
ColumnA |ColumnB
1 | a
2 | b
3 | f
4 | d
Sheet 3:
ColumnA |ColumnB
1 | match
2 | match
3 | mismatch
4 | match
If two lookup equal each other than match, otherwise no match, In B1 of Sheet3:
=IF(VLOOKUP(A1,Sheet1!A:B,2,FALSE)=VLOOKUP(A1,Sheet2!A:B,2,FALSE),"Match","Mismatch")
And copy down.
Using Google spreadsheet, I need a column to show relative row numbering, so that:
Spreadsheet rows can be moved around, and numbering stays relative (meaning that if I move row number 12 between rows 4 and 5, this row becomes number 5, previous 5 becomes 6, etc.)
Using a condition based upon a cell value in a given row, the row numbering cell may be empty (or not); if empty, that row number is being skipped, and numbering takes back up in the next row where the condition is unmatched.
Here is an example:
| Row nbr | B col. | [Explanation] |
|---------|:-------:|-------------------------------------|
| R01 | Value 1 | |
| R02 | Value 1 | |
| R03 | Value 2 | |
| | Value 3 | Col. B value = 3 => Col. A is empty |
| R04 | Value 2 | Numbering takes up |
| R05 | Value 1 | |
| | Value 3 | Col. B value = 3 => Col. A is empty |
| R06 | Value 2 | Numbering takes up |
| ETC. | | |
Here, the condition (to skip numbering) would be "IF corresponding B cell = Value 3" (then skip numbering)
Right now, I'm using a formula that matches requirement #1 above:
=ROW(INDIRECT("A"&ROW()&":A"))-9
(The trailing "-9" is just an offset so numbering can start at 01 from row 10).
So basically, I need to adapt (or change) this code so that besides relative numbering, for row N, if corresponding B column cell value = XYZ, then A column cell is empty (vs. numbered): that row is being skipped, and numbering takes back up from N on the next row where the B cell value ≠ XYZ.
Here's a Google spreadsheet example.
Many TIA's.
I strongly recommend not to use ROW() with explicitly specified offset in formula because should you delete/add rows above your table, your will have to adjust formulas in all cells. Here's my solution (column A:A is row numbers, B:B - values, start adding formula in cell A10):
=IF($B10="Value 3","",ROWS($B$10:$B10)-COUNTIF($B$10:$B10,"Value 3"))
Or if you insist on relative rows (change 10 to your offset from top):
=IF(INDIRECT("B"&ROW())="Value 3","",ROWS(INDIRECT("B"&10&":B"&ROW()))-COUNTIF(INDIRECT("B"&10&":B"&ROW()),"Value 3"))
In excel, how do I write a formula that does the following:
In a certain cell range, if the cell contains a non-numeric entry, add one, or else add the number the cell contains.
for example
4
xyz
def
bc
2
0
=9
or
1
ab
cd
2
af
=6
Contents of the data A1:A6
4
xyz
x
2
y
0
Write the following formula in cell B1
=SUM(A1:A6)+(COUNTA(A1:A6)-COUNT(A1:A6))
I would use an array function:
{=SUM(IF(ISNUMBER(A1:F1);A1:F1;1))}
Enter by writing "=SUM(IF(ISNUMBER(A1:F1);A1:F1;1))" and pressing Ctrl+Shift+Enter.
A | B | C | D | E | F | G
--+---+---+---+---+---+---+---
1 | 4 | a | b | c | 2 | 0 | {=SUM(IF(ISNUMBER(A1:F1);A1:F1;1))}
What I would do is write a the formula
=ISERROR(Cell+0, 1)
next to each cell, and then sum across these cells.
What the formula does is it returns the value of the cell if the cell is a number, and it returns the number 1 if the operation "cell + 0" errors out (e.g. when the cell's value is not a number).
See the picture below for how i applied this to your first example.