Multiple Return Vlookup Horizontal match range with Vertical return range - excel

I have binary data running in the horizontal direction: For example the match ranges look like:
Mike 0 1 0 0 0 1
Julie 1 1 0 1 1 0
Joe 1 1 1 0 0 0
And the return Range contains textual data:
Q1: What is the capital of NY?
Q2: What is the capital of Ohio?
Q3: What is the capital of Washington?
.
.
.
I need to match every occurrence of 1 with corresponding data that runs in the vertical direction. i.e. horizontal index corresponding with vertical index. I have found several instances where a multiple return vlookup was accomplished by using:
=IFERROR(INDEX(return_range,SMALL(IF((1=match_range),ROW(match_range)-1),ROW(1:1)),2),"")
However this isn't working. I assume it isn't working because it is meant for two vertical data sets. I have tried switching the "row" for "column" in the function, but didnt have any luck.
Also, the match range and return range are on different sheets.
The match range (in horizontal direction) is binary information on whether a question was answered correctly. The return range is the corresponding set of questions (in vertical direction). Therefore, the output would be an array:
Mike: Q2 Q6
Julie: Q1 Q2 Q4 Q5
Joe: Q1 Q2 Q3
How can this function be modified to accomplish this?

To get the correct row in an array that then can be used in other formula we use INDEX:
INDEX($A:$G,MATCH($I2,$A:$A,0),0)
This will return all the values in Column A through G in the row where the name matches that in I2.
It can be used as such in a INDEX/AGGREGATE Function:
=IFERROR(INDEX($A$1:$G$1,AGGREGATE(15,6, COLUMN(INDEX($A:$G,MATCH($I2,$A:$A,0),0))/(INDEX($A:$G,MATCH($I2,$A:$A,0),0)=1),COLUMN(A:A))),"")
My best guess as to your data set up:
Use a formula like this:
=IFERROR(INDEX($I:$I,AGGREGATE(15,6, COLUMN(INDEX($A:$G,MATCH($K2,$A:$A,0),0))/(INDEX($A:$G,MATCH($K2,$A:$A,0),0)=1),COLUMN(A:A))),"")

Related

Presenting a value based on number or text in cell

I have a list of 4 values in Sheet1 and 4 values in Sheet2.
In Sheet3 I will combine a random selection of these numbers and return the value in a column. (edit: no random selection from Excel, its a part picked from a bucket)
(A fifth column in Sheet3 will be used to do calculations with ValueS1 and ValueS2)
Sheet1
NumberS1
ValueS1
1
17.10
2
17.20
3
17.12
4
17.15
Sheet2
NumberS2
ValueS2
1
16.10
2
16.20
3
16.12
4
16.15
Sheet3
NumberS1
NumberS2
ValueS1
ValueS2
1
3
17.10
16.12
2
2
17.20
16.20
4
1
17.15
16.10
3
4
17.12
16.15
What kind of function can give the desired return?
I have looked into examples using "Indirect" but cannot see how they will solve my problem.
for the randomization: =ROUNDUP(RAND()*4,0)
rand() gives you a number between 0 and 1, so rand()*4 gives you a number between 0 and 4.
roundup(x,y) round up the number x with y digits you want to round the number up to (in our case 0).
for import the right number from sheet 1 or 2: =VLOOKUP(A1,Sheet1!A1:B2,2,0)
A1 - The value you look for in sheet 1 or 2.
Sheet1!A1:B4 - The array he look for your value on the firs column, always on the first column.
2 - The column you want to import the value from. (because we write an array of tow columns. we can write here only 1 or 2)
0 - it's an Optionally index (0 or 1). o is if you want an exact match of the return value.
Regular Lookup could do:
=LOOKUP(A2:A5,Sheet1!A2:A5,Sheet1!B2:B5) in Sheet3!C2
And
=LOOKUP(B2:B5,Sheet2!A2:A5,Sheet2!B2:B5) in Sheet3!D2
Note that LOOKUP will give the result to the closest match smaller than the search value.
Or VLOOKUP:
=VLOOKUP(A2:A5,Sheet1!A2:B5,2,0) / =VLOOKUP(B2:B5,Sheet2!A2:B5,2,0)
VLOOKUP will error if the value is not found (the way used above). It uses arguments like this:
=VLOOKUP(What you want to look up, where you want to look for it, the column number in the range containing the value to return, return an Approximate or Exact match – indicated as 1/TRUE, or 0/FALSE)
Office 365 has XLOOKUP which combines the logic of the two above and some more:
=XLOOKUP(A2:A5,Sheet1!A2:A5,Sheet1!B2:B5,"value not found",0)
XLOOKUP uses the following arguments:
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])

How to ignore values already counted in previous rows for cumulative count

I have a dataset that looks like this:
Sample Species1 Species2 Species3 Cumulative count
1 1 1
2 1 1 2
3 1 2
4 2 2
5 1 2 1 3
I would like to count every new species added by each sample. So in the example above, samples 3 and 4 don't add any new species to the total number of species, so their cumulative count remains the same (I am trying to create a species accumulation curve).
I have tried this, but cannot get it to work with numbers >0 (for instance), rather than text:
How to ignore data previously counted by countif and return a specific value in cell
Essentially, I need something to check if the species in the current row were already present in previous rows.
The goal is to produce a graph like this, so I can determine where sampling effort begins to have a diminishing return (in number of species):
Is there an excel formula I could use to fill the 'Cumulative count' column and return the results above? I should also mention that a short solution would be best, because I have 35+ species and the formulas can get long and complicated very quickly. Any assistance would be appreciated.
Going horizontal is easy smaller formula:
=SUMPRODUCT((B3:D3>0)*1,(B$2:D2<=0)*1)+E2
.......
=SUMPRODUCT((B6:D6>0)*1,(B$2:D2<=0)*1,(B$3:D3<=0)*1,(B$4:D4<=0)*1,(B$5:D5<=0)*1)+E5
I found a method but this probably can be refined a bit:
For our first Cum Count Row:
=COUNTIF(B2:D2,"<>" & "")
For each thereafter:
=IF(AND(B3>0,SUM(B$2:B2)<=0),1,0)+IF(AND(C3>0,SUM(C$2:C2)<=0),1,0)+IF(AND(D3>0,SUM(D$2:D2)<=0),1,0)+E2
.....................
=IF(AND(B6>0,SUM(B$2:B5)<=0),1,0)+IF(AND(C6>0,SUM(C$2:C5)<=0),1,0)+IF(AND(D6>0,SUM(D$2:D5)<=0),1,0)+E5
A shorter solution is a UDF, and is provided here by JvdV:
stackoverflow.com/questions/51980149/count-column-if-it-contains-a-filled-cell-in-excel/51980258
Well, I guess if you want to work without any helper rows to use the
COUNTA funtion a smooth way could be a UDF, possibly like so:
Function CountColumns(RNG As Range) As Long
Dim COL As Range
For Each COL In RNG.Columns
If Application.WorksheetFunction.CountA(COL) > 0 Then CountColumns = CountColumns + 1
Next COL
End Function

Google Sheets Arithmetic Search

I have two Google sheets tabs:
I.)
--A-- --B--
--1-- type lessThan10Apart
--2-- Car 1
--3-- Plane 0
II.)
--A-- --B-- --C--
--1-- type sourceA sourceB
--2-- Car 1 100
--3-- Plane 10 100
--4-- Car 2 4
My question is how to create the lessThan10Apart formula above. lessThan10Apart should match up the type from sheet I to sheet II and only count the rows that: Are less than 10 units between A and B. But you can also imagine wanting to do any kind of arithmetic between columns B and C and running a COUNT.
My first attempt is something along the lines of:
=COUNTIFS('sheetII'!A:A),$A2, //Match column A
ABS('sheetII'!C:C-'sheetII'!B:B)<10 //Doesn't work!
)
The problem is that you can't seem to be able to do range calculations like this in COUNTIFS.
For the count (per F4 in supplied image),
=SUMPRODUCT(--(ABS(B2:B4-C2:C4)<10))
For the validSum (sum of absolute difference between B & C; per G4 in supplied image),
=SUMPRODUCT(--(ABS(B2:B4-C2:C4)<10), ABS(B2:B4-C2:C4))
Do not use full column references. Minimize your referenced ranges.
Discard the Car text in E4 in the above image.

How to count the values in ranges in Excel

I have two columns as shown below. Group values is 0,1,2,3,4 and scores is from 0 to 80. I want to count how many 0s (1s, 2s, 3s, 4s) are present for scores between 0 and 10; 10 and 20; 20 and 30 etc.
I am thinking to use Excel pivot table. But I am stuck - how could I achieve this?
Group scores
1 8.56163
2 34.3649
2 12.2291
0 8.75357
2 8.75967
2 5.87806
0 9.33751
2 32.0303
0 43.5567
2 11.1044
2 24.9266
1 18.9314
-------- result should look like below --------
scores group count
0-10 0 2
0-10 1 1
0-10 2 2
0-10 3 0
0-10 4 0
10-20 0 0
10-20 1 1
10-20 2 2
...
------ PS I have solved this problem using matlab. But it would be nice to see someone do it in Excel.
---------------- thanks for all the anwers. I really appreciate it. I have accepted the 1st answer.
I apologize for my previous answer. You can do binning with PivotTable.
select your whole two columns (A1:B13), insert PivotTable
under rows, put your "Group"
under columns, put your "scores"
under values, put your "Group"
click that last one ("Group" within the values quadrant) and change it to count, not sum
intermediate result:
Now in the resulting pivot table, right click on a colum and select "Group and show detail". You can configure your bins there.
Result:
One option is to use a pivot table, but another option is to use COUNTIFS, e.g.:
=COUNTIFS($A$2:$A$13,"="&$F2,$B$2:$B$13,">="&D2,$B$2:$B$13,"<="&E2)
In practice:
You could just use simple countif formulas:
Type out first criteria into cells. D1 = 0, E1 = 1, F1 = 2 etc.
Now you can just say =COUNTIF($A$2:$A$13,D1) and just drag that out.
The other column would require countifs.
Lets say D3 is blank E3 = ">10", F3 = ">20", etc.
Now D4 = "<=10", E4 = "<=20", F4 = "<=30", etc.
Now you can use =COUNTIF($B$2:$B$13,D4) for your first criteria and =COUNTIFS($B$2:$B$13,E4,$B$2:$B$13,E3) for the next criteria and just drag that out.
Hope this helps, good luck!
Please try:
This uses Grouping (by decade) for the Row labels.
To Group, right-click on one of the entries under Row Labels and Group..., then select enter Starting at:, Ending at: and By: to suit:

Excel - Finding Max value in a column

I have an Summary sheet set up data set up as follows-
Cat A Cat B Cat C Cat D
Name 1 0 0 0 0
Name 2 2 3 2 2
Name 3 2 2 2 2
Name 4 3 2 2 3
Name 5 2 3 2 3
I also then have separate tabs for each of Name1 through to Name 5.
The summary sheet contains the maximum values for each category from each tab. So the Cell at Cat A Name 1 should show the maximum value on Sheet(Name1) in the Cat A column.
So far so good. However each tab may not contain the same categories, so therefore I would like teh summary sheet to check the maximum value in each column by doing a search on the Cat name.
So far I have this-
=MATCH(Overview!S$1,Name1!$C$1:$V$1,0)
Which returns the column number with the right Category, in this case 13. So I can find the right column. What I am struggling with is to now find the maximum value in the column.
Can anyone help?
Thanks
IAssuming your search range goes to row 1000:
=MAX(INDEX(Name1!$C$2:$V$1000,0,MATCH(Overview!S$1,Name1!$C$1:$V$1,0)))
The 0 Row argument in Index means to select the entire column.
The Offset function is your key here.
After you've got the value from the match, you can pass it to the offset to get the correct column.
So, for example, you probably want something like:
=Max(Name1!$C1:$C2000)
But you don't know whether you should use the C column or the D column or whatever, in this case, it was 13, so is that the P column? (c=3, the match was 13 so 3+13 = 16 = P?), so I think you want something like this:
=Max(Offset(Name1!$C$1:$C$2000, 0, [result of your match expression] - 1))
Here's an example of what I think you want in GoogleDocs:
https://docs.google.com/spreadsheet/ccc?key=0Ai45AJPc2AWMdGRlZXNIdlZBaHJxc01qVlJWa1N1WXc

Resources