2nd match, match multiple criteria, no VBA function/VBA code - excel

Good Morning everyone.
I've got an array excel function which works based on 3 criteria as follows:
=IFERROR(INDEX('merged wz'!W:W,MATCH(1,('q log wz'!$C55='merged wz'!$M$1:$M$8000)*('q log wz'!$A55='merged wz'!$K$1:$K$8000)*(28='merged wz'!$P$1:$P$8000),0)),"No data")
now it works good for true and falses in the last part for one of the column datas where I need to return first match
(28='merged wz'!$P$1:$P$8000)
but this array will always have 2no trues and in other column I would like to modify this function so it replaces first true in array with false so it will return true only for the second match.
Any ideas how to do it? Thanks in advance.

Just showing one way of dealing with what you are trying:
Formula (CSE-entered) in D1:
=INDEX(C1:C8,SMALL(IF((A1:A8="a")*(B1:B8="x"),ROW(C1:C8),""),2))
This will return the 2nd match where column A=='a' and B=='x'.

Related

Formula to get all matching values and return all occurrences of match in order based on 1st occurrence of a value in another column

This one is interesting and I am not even sure if it can be done with a formula. I can do it with a macro but I want a formula for this one.
I have 2 sets of data. The 1st set contains some dates and a true/false field and an ID number. The 2nd set of data contains some dates and ID number and a blank column. Now I need to find the 1st occurrence of an ID number in the 2nd dataset and then based on that check the 1st dataset for matching numbers and then check if value is false in the 3rd column. If that value is false return date from 2nd column.
Now I can go this on my own with a vlookup if I only wanted the 1st occurrence but I need to get all matches. The dates in the 2nd column can be ignored they are not part of the formula.
Here is an example of what the data should look like after applying the formula. I need the false dates to be returned. I know I can build this as a function but I really need to do a formula if possible.
Update:
I did find JOINTEXT() however that does not work in excel 2013 :| so that is out of the question.
You can use INDEX and AGGREGATE combination:
=IFERROR(INDEX(B:B,AGGREGATE(15,6,ROW(A:A)/((G2=A:A)*(0=--(C:C))),COUNTIF($G$2:G2,G2))),"")
In my example in column C are boolean values. If you have text there then change part of formula (0=--(C:C)) to ("FALSE"=C:C)

Match to return all values instead of just first in a column

I am trying to find all the cells that have the value 21 in the column AGE. I currently have the following formula which works fine with returning just the first TRUE value:
=MATCH(21,AGE,0)
However, it does not continue through the whole column to return the rest of the results. Any help will be extremely appreciated.
Use AGGREGATE like this:
=IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($B$2:$B$7)/($B$2:$B$7=21),ROW(1:1))),"")
as it is dragged/copied down it will get the next in the line, until it finds no more, then it will fill the cell with "".

IF Values match return true

I am trying to get some code working but when I change a target cell into a range of cells I get an error #VALUE!
this code works
=IF(AND(A1=Sheet2!A2,B1=Sheet2!B2),"TRUE","FALSE")
but if I add a range I get #VALUE! Error
=IF(AND(A1=Sheet2!A2:A10,B1=Sheet2!B2:B10),"TRUE","FALSE")
Update : Here is an example of what I am trying to achieve
Any help would be much appreciated
Many Thanks,
And
Different approach from your logic statement. Instead it looks through your table and match the name with the row and the column with the date selected and the pulls the value at that location.
=INDEX($B$7:$G$8,MATCH($B3,$A$7:$A$8,0),MATCH(C$1,$B$6:$G$6,0))
IMPORTANT: The names in you B3:B4 area have to be unique and spelled identical to your A7:A8 area. That included trailing or leading spaces that you may accidentally drop in.
Adjust reference ranges to match your need if tables are on different sheets of your workbook.
THIS IS AN ARRAY FORMULA - Hit Ctrl+Shift+Enter While still in the formula bar
=INDEX(B2:B10,SMALL(IF(A2:A10=A1,IF(B2:B10="ONCALL",ROW(A2:A10)-1)),1))
=INDEX(B2:B10, - Look through B2:B10 and return the row number calulcaulated by:
SMALL(IF(A2:A10=A1,
IF(B2:B10="ONCALL",
ROW(A2:A10)-1)),1))
This is building an array of row numbers minus 1 where both IF statements are true (Date matches and "ONCALL" present), SMALL then returns the nth value in ascending order - I have asked for the 1st match (or the smallest row number) which INDEX then uses to return the result.

How to skip every nth row in Excel column Sum

I have a table which I have copied from the internet and pasted in Excel. The data pasted is however not clean. I want to add the 1st, 4th, 7th, 10th... row from the column, while skipping 2,3,5,6,8,9...th row. And I'd like that solution to be in one cell, that is without adding a helper column.
Here is a snapshot of my demo table. Hope this gives you an idea of what I am trying achieve.
I've searched the internet found this question on SO. But I just can't modify the formula to get around my solution. Any help is greatly appreciated.
Seeing you have a header in your column.
Enter the following formula in your desired cell where you want the sum value
=SUMPRODUCT((A2:A13),(--(MOD(ROW(A2:A13),3)=2)))
Explanation:
MOD(ROW(A2:A13),3)=2 Checks for rows where row_number %% 3 = 2 and returns an array of boolean(TRUE or FALSE for each match)
Output : =SUMPRODUCT((A2:A13),(--({TRUE;FALSE;FALSE;TRUE;FALSE;FALSE;TRUE;FALSE;FALSE;TRUE;FALSE;FALSE})))
The double negative converts the boolean values to numeric 1(TRUE) or 0(FALSE).
Output: =SUMPRODUCT((A2:A13),({1;0;0;1;0;0;1;0;0;1;0;0}))
SUMPRODUCT multiplies the above array with the data array of A2:A16 and adds the product result.
How about using sumproduct? This function is greatly versatile and should do the trick. The idea is that the double negative sign casts the boolean to a one or zero so your false elements (aka any n where n%3 <> 1) get multiplied by zero so they are, in effect, excluded from your sum.
=SUMPRODUCT(--(MOD(ROW(A1:A16), 3)=1), A1:A16)

if two columns contain specific text, return true in separate column

I am having an issue with coming up with a formula for excel that returns true in a column if two columns before it contain a specific word.
For example,
If Column A and Column B contain "Snow Valley" and "Rain Valley", then Column C returns "TRUE" only if both A AND B contain "Valley"
Does anybody know of an efficient method to do this? Thank you.
As follow up from comments, this works:
=COUNTIFs(A1,"*Valley*",B1,"*Valley*")>0
=not(or(iserr(find("valley",B1)),iserr(find("valley",C1))))
Find() returns #VALUE! If it does not find any match, which explains why i need the iserr(). Iserr() will be True if nomatch and I do Or() to catch the True if any of the two Match() did not contain the word valley. So the Not() makes the True/false behave like you want.

Resources