I'm trying to figure out a sleeker method for determining the value of a cell based on criteria defined in a given range. To put it bluntly, I have a column for standard viscosity, standard temperature, and measured temperature. I'm needing to create a fourth column that will select the standard viscosity based on the measured temperature. For example, if measured temperature is greater than or equal to 0oC and less than 1oC: return standard viscosity for 0oC.
My issue is that I have a large range and find it to tedious to create a custom expression for each range. I've created a nightmarish function that was composed of IF(AND()) statements but find this exhausting, especially if I try to create an expression for a 0-200oC scale in single digit increments.
Here is a sample of a code that works but is quite cumbersome:
=IF(AND(G8>=$C$7,G8<$C$8),$D$7,0)+IF(AND(G8>=$C$8,G8<$C$9),$D$8,0)+....
or
=IF(AND(measured temp>=0,measured temp<1),$D$7,0)+IF(AND(measured temp>=1,measured temp<2),$D$8,0)
How could I approach this in a sleeker manner?
You can achieve this by the VLOOKUP function.
=VLOOKUP(G8;$C$7:$D$...;2;TRUE)
Replace the three dots with the index of the last row of your table.
The first argument of VLOOKUP is the value to search for; the second argument is the range whose first column is to be searched for the value; the third argument is the index of the column containing the values to return (within the range, so 2 means the second column within the range, which is D in your case); TRUE means that you do not want to search for an exact match, but that the column to be search is an ordered list of values defining intervals.
Edit:
With MATCH and OFFSET (guessed, not tried), if column with result values is left relative to column of criterion values:
=OFFSET($C$7;...;MATCH(G8;$C$7:$C$...;1) - 1)
Replace the first three dots with the position of the result column, relative to column C (so 1 if it's column D, and -1 if it's column B), and the second three dots with the index of the last row of your range, as above.
Edit2:
INDEX instead of OFFSET is even better, se pnuts's answer and the comment below:
=INDEX($D7:$D...;MATCH(G8;$C$7:$C$...;1))
If your measured temperature is say in F2 and your data table is A:C please try:
=INDEX(A:A,MATCH(F2,C:C))
Related
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()
I have a table that I want to export the data to a table that contains a column of names, dates and attendance so that it takes the values from the table
like this picture
You want INDEX and MATCH. See the formula at this Google Sheet, but it will work the same in Excel This is the top of the two examples:
https://docs.google.com/spreadsheets/d/1bvp6-Jb82A-AEOxvnMLzUNxWUSCKt1merc2nfSt3viE/edit?usp=sharing
=INDEX(F10:M13, match(O13, F10:F13, 0), match(P13, F10:M10, 0))
INDEX takes a range, and two numbers, one for the row and one for the column, and returns the value (or reference) at that intersection. You can pass false or null for either one of the numbers and return the entire row or column of the range, or if you are working with a single dimensional array, like a row or a column, you can just pass one number to it.
MATCH takes a value and a range (and an optional lookup type) and returns the index of that value in the range.
So using INDEX with two MATCHes, you can find the row and column of the data you are looking for.
DOCS:
https://support.microsoft.com/en-us/office/index-function-a5dcf0dd-996d-40a4-a822-b56b061328bd
https://support.microsoft.com/en-us/office/match-function-e8dffd45-c762-47d6-bf89-533f4a37673a
It is possible to do this with VLOOKUP, but I find INDEX/MATCH to be more intuitive and more flexible. Here is a VLOOKUP implementation. It is the bottom of the two examples on the demo sheet:
=vlookup(O16, F10:M13, match(P16, F10:M10, 0))
As you can see, you still pass it the data range and use match to get the column, but VLOOKUP will find the row with the lookup value for you, as long as it is in the first column. INDEX/MATCH lacks this limitation, and I find the arguments more logical: INDEX(range, row, column) vs VLOOKUP(lookup value, range, column).
I am trying to calculate the point score for which matches the findings column from the data. There are many different sections since there are different categories within the data. What kind of forumla could I use to determine the score based on the different categories? I considered use vlookup but that only works for the first section of the point data.
The objective is to return either 0,1 or 2 based on the category of the data such as media and the finding values
Excel Data
You can use a combination of INDEX, MATCH and OFFSET, with a helper row:
For formula I'm using there is as follows:
=INDEX(OFFSET(INDEX($A$2:$A$12,MATCH(C18,$A$2:$A$12,0)),3,1,1,3),MATCH(B18,OFFSET(INDEX($A$2:$A$12,MATCH(C18,$A$2:$A$12,0)),2,1,1,3),1))
OFFSET(INDEX($A$2:$A$12,MATCH(C18,$A$2:$A$12,0)),3,1,1,3) this part gives the range for points matching the category. I use something similar to get the range matching the points.
First, INDEX and MATCH gives the cell containing the category. I use OFFSET to move that reference 3 cells down, 1 cell right, keep the height and increase the width to 3. For instance, in D2, INDEX and MATCH gives me cell A7. Offsetting that using the values I mentioned earlier means that the result of offset will be the range B10:D10.
Using the same logic, I get the range B9:D9. From that range, I use MATCH to get the highest column in which the value in range B9:D9 is smaller than the listing value, in this case the value 100 is the largest value that is smaller than 165, so I get the result 3 from MATCH. This fed into INDEX gives the corresponding points.
But you can do without OFFSET if you can picture the different arrays in your head using only INDEX and MATCH:
=INDEX($B$5:$D$15,MATCH(C18,$A$2:$A$12,0),MATCH(B18,INDEX($B$4:$D$14,MATCH(C18,$A$2:$A$12,0),0),1))
I am not into Excel and I have this problem trying to sum the values of 2 different column and put this result value into a cell.
So basically I have the D column containing 2 values (at the moment only 2 but will grows without a specific limit, I have to sum all the values in this column). These value are decimal values (in my example are: 0,3136322400 and 0,1000000000).
Then I have an I column containing the same type of value (at the moment only one but also the values in this column can grow without a specific limit...in my example at this time I have this value −0,335305)
Then I have the K3 cell where I have to put the sum of all the valus into the D column and all the values into the I column (following my example it will contain the result of this sum: 0,3136322400 + 0,1000000000 −0,335305.
Following a tutorial I tried to set this simple forumla in the K3 cell:
=SUM(A:I)
The problem is that in this cell now I am not obtaining the expected result (that is 0.07832724) but I am obtaining this value: 129236,1636322400.
It is very strange...I think that maybe it can depend by the fact that the D and the I column doesn't contain only number but both have a textual "heder" (that is the string "QUANTITY" for both the cells). So I think that maybe it is adding also the number conversion of this string (but I am absolutly not sure about this assertion).
So how can I handle this type of situation?
Can I do one of these 2 things:
1) Adding the column values starting from a specific starting cell in the column (for example: sum all the values under a cell without specify a down limit).
2) Exclude in some way the "header" cells from my sum so the textual values are not considered in my sum.
What could be a smart solution for my problem? How can I fix this issue?
The sum function can take several arguments.
=sum(d2:d10000, i2:I10,000, more columns )
This should remove the header from the calculation.
If you turn your data into an Excel Table (Insert > Table), you can use structured referencing to address a table column, excluding the header.
=SUM(Table1[This Header],Table1[That Header])
Then you don't need to reference whole columns. If you add new data to the table, the formula will take that into account.
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.