How to do lookups in Excel with multiple criteria - excel

I have a question. I'm collecting social media statistics (likes, shares, comments, etc.), and one thing that I'm trying to do is get Excel to tell me the date that the largest number of hits occurred, what post it was on, and what type it was.
I'm part of the way there--I can get Excel to tell me what the highest number is (MAX, easy!), but I can't get it to lock in the date properly.
The way I've got it set up is: there's a single row for each day of the month, with the dates in column A, and additional columns for the types of engagements I'm tracking. At the very bottom of the table is a row with all the MAX values from each column (so in other words, column B will have Likes, column C is shares, and so on, so I can enter a new value for each analytic every day.
Essentially, what I'm trying to do is get Excel to do this, in order:
Look along the row with all the MAX values to find the highest value;
Look up above that (same column) into the data rows until it finds that MAX value;
Take note of the row where it found that MAX value, and return the value of the date from Column A
Make sense? I've got a formula set up with INDEX and MATCH, but while it is giving me the correct numbers for the top value and what type of analytic it is, I can't seem to get the correct date (what it looks like it's doing is counting the columns from left until it finds the value for #2, then counting that number of rows down).
Can anyone help?

You can do this by nesting MAX, MATCH and INDEX
Mockup of your data
The Formula
=INDEX(Table1[Date], MATCH(MAX(Table1[#Totals]), INDEX(Table1, , MATCH(MAX(Table1[#Totals]), Table1[#Totals], 0) ), 0 ) )
Explanation of the Formula
Of course, you don't have to use a Table. A formula for the same data, without Structured References
=INDEX(Sheet1!$K$2:$K$10, MATCH(MAX(Sheet1!$K$11:$P$11), INDEX(Sheet1!$K$2:$P$10, , MATCH(MAX(Sheet1!$K$11:$P$11), Sheet1!$K$11:$P$11, 0) ), 0 ) )

Related

Function to search for specific number and then to further search for the prefix

I have a huge amount of data to process in which 4 points with a related prefix needs to be subtracted from each other.
Data consists of ID and x value
Example
ID = 290.12, 290.03, 290.06, 290.09, 300.12, 300.03, 300.06, 300.09, 301.12, 301.03, 301.06, 301.09
(let's call prefix a "ring number" and suffix time on the clock)
X value = any numerical value for each ID assigned
What I'm hoping to do is to search for the first number before the dot i.e. 300 and then subtract the value of 300.06-300.12 in one cell and in another cell 300.03-300.09.
(The subtraction is just an example, how I need to manipulate with the numbers is slightly more complicated, but I got this one under control)
This is my actual Data and what I need to produce is to the right of the raw data. At the moment, I'm doing it manually for each set of "rings"
Anyone knows how to approach this? I'm thinking vlookup, but I'm not very proficient in excel.
New Excel
I tried vlookup, but I don't know how to construct the formula and I run out of ideas.
Edit:
I found out that REDUCE is no requirement in this case, so it can be shortened to:
=SQRT(SUM(((INDEX(B:D,XMATCH(I3+0.09,A:A),SEQUENCE(1,3))-INDEX(B:D,XMATCH(I3+0.03,A:A),SEQUENCE(1,3)))^2)))
You could change +0.09 and +0.03 to your needs and may reference them using LET() for easy maintaining:
=LET(id,I3,
_id1,0.09,
_id2,0.03,
SQRT(SUM(((INDEX(B:D,XMATCH(id+_id1,A:A),SEQUENCE(1,3))-INDEX(B:D,XMATCH(id+_id2,A:A),SEQUENCE(1,3)))^2))))
Previous answer:
=LET(
id,I3,
_id1,0.09,
_id2,0.03,
SQRT(
REDUCE(0, SEQUENCE(1,3),
LAMBDA(x, y,
x+((INDEX(B:D,XMATCH(id+_id1,A:A),y)
-INDEX(B:D,XMATCH(id+_id2,A:A),y))
^2)))))
This formula looks for the matching value of the id value I3 + _id1 minus the matching value of id value + _id2 for columns B to D and adds the ^2 results per column. Then it calculates it's square root.
You can change _id1 and _id2 to your needs.
To calculate the Delta (as shown) at once you could use:
=LET(id,I3,
_id1,0.09,
_id2,0.03,
_id3,0.12,
_id4,0.06,
x,SQRT(SUM((INDEX(B:D,XMATCH(id+_id1,A:A),SEQUENCE(1,3))-INDEX(B:D,XMATCH(id+_id2,A:A),SEQUENCE(1,3)))^2)),
y,SQRT(SUM((INDEX(B:D,XMATCH(id+_id3,A:A),SEQUENCE(1,3))-INDEX(B:D,XMATCH(id+_id4,A:A),SEQUENCE(1,3)))^2)),
(x-y)*1000)
You can have a column of unique values of the integers and a new column where you reference these values as id and drag down the formula to get your row by row result
In another column you can refer to these columns and sort per the second column using SORTBY()

Excel Array Formula, Multiple criteria

I have a table in which multiple weeks of data is stored and I'm trying to return a value based on 2 criteria.
Column A of the data sheet contains the date the report was ran (Always on the same day of the week - 24/05/17, 31/05/17 etc)
I've managed to return the value of column H by using an array formula, based on a cell value (Date) in ''Issues Data Quality Overview'!$B$4' using the following formula:
{=IFERROR(INDEX('Issues Log'!$H$1:$H$20000,SMALL(IF('Issues Data Quality Overview'!$B$4='Issues Log'!$A$1:$A$20000,ROW('Issues Log'!$A$1:$A$20000)-MIN(ROW('Issues Log'!$A$1:$A$20000))+1,""), ROW(A2))),"")}
That returns a value such as "IID-10225-22".
Problem:
Now I need to look up that value in the same table, based on a date in another cell, and return column X. (essentially adding the returned value as a criteria).
In all honesty I'm lost as to how I'd do this.
#Matthew. I understand your formula gives the list of values in column H with column A values matching 'Issues Data Quality Overview'!$B$4 in an ordered list.
Does your Issues Log, column H have multiple occurrence of the same value? (example: IID-10255-22 can have a value in Issues Log, column A that is not the same value as 'Issues Data Quality Overview'!$B$4).
If not, it doesn't make sense to use the result as a lookup value to get column X, you can simply change the code to:
{=IFERROR(INDEX('Issues Log'!$X$1:$X$20000,...}
If it does have multiple occurrences and you want to get the first occurrence of the result in column H and get the value in column X, best to add a formula right next to your array formula and do a VLOOKUP.
I've scrapped the array formula, as it really slowed down the processing speed. Instead I've created a Unique ID (=IssueID&Date) and VLookup'd that.

Given a value in an table of values in Excel, how to return the corresponding value from the first column/row

I have the following data-set:
Given a number that occurs only once in the data range B2:E5, I would like to use a formula that returns the corresponding date value. The date values are given in the first column (A2:A5). I would also like to be able to return the corresponding hour value using a similar formula. Note, it is not necessary to return the hour and the date for a given value using the same formula.
Example: In the image of the data-set above – given the number 5, I would like to return the corresponding date. In this case, the formula would return the date value 03/01/2013. Similarly, I would also like to be able to return the "hour 3", given the same initial value.
Maybe the answer to this question is quite straight forward, but as of yet I have had no luck in figuring it out. Some things that I have tried, but to no avail, are the following: VLOOKUP/HLOOKUP, LOOKUP, a combination of INDEX+MATCH, and a combination of INDEX+MATCH+MATCH.
Any help is very much appreciated.
Given that Number to Find is unique, you can use this:
For the date in Column 1
=INDEX(Table1[Column1],MAX((NumToFind=Table1 )*ROW(Table1 ))-1)
For the hour in the Headers fields:
=INDEX(Table1[#Headers],1,MAX((NumToFind=Table1)*COLUMN(Table1)))
The above formulas are array formulas and must be confirmed by holding down CTRL + SHIFT ENTER
The -1 in the first formula is to compensate for the fact that the table starts in Row 1, with the data starting in Row 2, and the formula determines the absolute row number; if it starts other than in A1, different compensating values will be required.

Retrieve the cell reference of the first non-blank cell in a column

I have a data set (discrete monthly return series) with two dozen columns representing data series, c.100 rows representing month-end time-series. The data in the set represents the monthly performance of each data set.
Each series has run for a different length of time and is updated to a different length of time.
My conundrum is; I am looking to find, for each series, the dates of both the earliest data point and the most recent data point. I was hoping to do this by way of referencing the row headers (date) in column A. To do this I would need to know the row number of the earliest data point.
I can get the value of the earliest data point using a CSE IndexMatch, but what I really need is the reference.
EDIT
Tom, this is the data set;
As you can see, each data set starts (and finishes) at a different date.
In a summary sheet I am putting the date range for which each respective data series has data, that is why I need the row value (so that I can lookup the dates).
So your formula was fine, you just needed to MATCH in column G and INDEX into column A:-
=INDEX('Discrete Monthly Returns'!A3:A1048576,MATCH(FALSE,ISBLANK('Discrete Monthly Returns'!G3:G1048576),0))
I appreciate that you would want the start date to appear somewhere else, but this is just an illustration of how to use the formula
This example teaches you how to find the cell address of the maximum value in a column.
First, we use the MAX function to find the maximum value in column A.
Second, we use the MATCH function to find the row number of the maximum value.
Explanation: the MATCH function reduces to =MATCH(12,A:A,0), 7. The MATCH function returns the position of the maximum value in column A. Set the third argument to 0 to return an exact match.
Finally, we use the ADDRESS function to return the cell address.
Explanation: the ADDRESS function reduces to =ADDRESS(7,1), $A$7. The first argument specifies the row number. The second argument specifies the column number.
http://www.excel-easy.com/examples/locate-maximum-value.html
The answer is copy-paste work from the above link, but pasted here as reference.

Count If match multiple fields: First field by initials, second field if date has been filled

I'm trying to create a simple tracker. In columns B and C, tasks are tagged with an author, and then the author fills in a completion date.
Above is a dashboard that counts items for easy viewing. I countif for the total, but have not been able write a formula for the complete column. I've tried countifs, but haven't been able to get the formula to work.
Thoughts?
Try below formula as per attached
OUTPUT
Using DSUM will probably send you in the right direction.
http://office.microsoft.com/en-gb/excel-help/dsum-HP005209069.aspx
From what I see in your image, you should do a Pivot table for your dashboard.
If you absoluteley have to (???) get along without a Pivot table, do the following:
start the dashboard in column B, so that column A just contains column header "Tasks" and data (no blank rows allowed!)
count the number of tasks as =COUNTA(A:A)-1 (-1 for the header)
count all other columns as =COUNTA(OFFSET(B5;0;0;$E$2;1)) (in this example you count column B, header is in B4, first data therefore in in B5, number in tasks from above formula in $E$2)
The Offset function basically gives back a range starting relative to a reference and being of chooseable size. So we start it at the first data cell and make it 1 column wide, and #oftasks rows deep
With COUNTIFS, assuming VH is in A8, Tasks/Author/Completed are in Row12 and you have or might have data up to Row1000:
=COUNTIFS(B$12:B$1000,A8,C$12:C$1000,">1")
copied down as required.
You can use SUMPRODUCT to find the amount completed per author.
=SUMPRODUCT(--($B$8:$B$16=A3),--($C$8:$C$16>1))
In this case, the "--" tells SUMPRODUCT to treat each cell in the array (I used the example by User2063626) individually so it starts at the beginning and checks if B8=VH and records the answer as a boolean (1 for TRUE or 0 for FALSE), in this case it does equal VH so it uses a 1. Then it checks to see if C8>1 (it will be if there is a date) and stores a 1. It then multiplies the two values together 1*1=1 to give you a value for the first row. It then moves on and does the check for B9 (gets a 1 because it is equal to VH) and C9 (gets a 0 because there is no date), multiplies the row result 1*0=0 and adds it to the previous result. It repeats for each row in the array and returns the count of rows where the author was VH AND there is a completed date (2).

Resources