Excel: vector-style lookup function without sorting - excel

I have an Excel (2007) spreadsheet which consists of several rows with the first few something like this:
CL DH HL SP FR CB TQ TT
37 33 27 27 26 25 31 26
25 26 33 32 28 25 26 25
21 28 26 31 26 28 26 28
They need to appear in this order since the first row also functions as headings for the columns.
What I need is to find the maximum number in each row, and to then return the column heading, i.e. for the data here the max in the first row is 37 so it returns CL, then HL and SP and so on.
Using the LOOKUP function in vector form requires the lookup row to be sorted (which isn't possible here since the order of each row is different and they all use the same headings), so I can't use that. Using HLOOKUP does not need data to be sorted but requires that the lookup row is the first row of an array, which again isn't practical here since I need the headings at the top.
Basically, what I think I need is a lookup-type function which uses vectors rather than a single array but does not require sorted data. Is this possible?

You can try index/match and large:
=INDEX($A$1:$H$1, 1, MATCH(LARGE(A2:H2,1), A2:H2, 0))
LARGE picks the greatest number, which is used by the exact match, and returned to INDEX to get the header.
EDIT: As tigeravatar rightfully pointed out, you can use MAX instead of LARGE:
=INDEX($A$1:$H$1, 1, MATCH(MAX(A2:H2), A2:H2, 0))

Related

In spreadsheet (Excel or Google Sheets), how to find the sum of multiple values with multiple rows of column headers criteria?

as in the above picture, I need to sum all the values within the table C8:V22 which match
the first three characters of column B(orange),
row 5 for the number(blue),
row 6 for the first character(green),
row 7 for the first three characters(yellow)
The desire result would be the sum of the number in red, which is 10001 + 10081 + 10161 + 10221 = 40464
I tried many different ways to write the formula, one of that is:
=INDEX($B$5:$V$22,
MATCH($D$26,LEFT($B$5:$B$90,3),0),
MATCH(($F$26=$5:$5) * ($G$26=LEFT($6:$6, 1)) * (H26=LEFT($7:$7,3)), 0))
and pressed Ctrl+Shift+Enter to make it as an array formula, but couldn't figure out where is the error.
Anyone could help on this? Thank you!
Edit: The following is a simplify table for easy reference:
1
2
3
a1
a2
b1
abc1
abdf2
abc2
111a
11
12
13
222a
14
15
16
111b
17
18
19
555a
20
21
22
333d
23
24
25
111a
26
27
28
in this case, the match values are 11 + 17 + 26 = 54
I also tried using combinations of functions such as SUMIFS, SUMPRODUCT, search, e.t.c. but still not able figure out the solution.
In your sheet:
=SUMPRODUCT((LEFT(B8:B22,3)=C26&"")*(C5:V5=E26)*(LEFT(C6:V6,1)=F26&"")*(LEFT(C7:V7,3)=G26&"")*C8:V22)
simply retrieve the sum using your parameters and converting in string to match exactly.
If you have Excel 365 you can use this formula:
=LET(data,C8:V22,
ruleColumnB,LEFT(B8:B22,LEN(D26))=TEXT(D26,"0"),
ruleRow5,C5:V5=F26,
ruleRow6, LEFT(C6:V6,1)=G26,
ruleRow7, LEFT(C7:V7,3) =H26,
SUMPRODUCT(data*ruleColumnB*ruleRow5*ruleRow6*ruleRow7)
)
)
Using LET makes the formula more readable - esp. if you name the rules according to your special context.
If you don't have Excel 365 you have to replace the single parameters within SUMPRODUCT with each range/formula

Dont know how to Select Cell Range For SLOPE Formula

Here is my problem. I want to use =SLOPE formula with a cell range that refers to another sheet with criteria: Date period between Oct-21 until Apr-22, the known_ys = Emiten Name and known_xs = IHSG.
I use this formula:
=SLOPE(IF(AND(Emiten!B:B>=Risk!$A$2;Emiten!B:B<=Risk!$B$2;Emiten!A:A=Risk!D17);Emiten!D:D);IF(AND(Indeks!B:B>=Risk!$A$2;Indeks!B:B<=Risk!$B$2;Indeks!A:A=Risk!$D$2);Indeks!D:D))
But it shows the result #VALUE!, can anyone please tell me where's the problem?
Thanks
AND only ever returns a single value. To simulate 'and' conditions within array constructions, use nested IF statements.
Also, you should not be using entire column references for such a construction, since it will be forced to process several million rows unnecessarily.
Try:
=SLOPE(IF(Emiten!B1:B10>=Risk!A2,IF(Emiten!B1:B10<=Risk!B2,IF(Emiten!A1:A10=Risk!D17,Emiten!D1:D10))),IF(Indeks!B1:B10>=Risk!A2,IF(Indeks!B1:B10<=Risk!B2,IF(Indeks!A1:A10=Risk!D2,Indeks!D1:D10))))
adjusting the last row referenced (10 here) to a suitably low, though sufficient, upper bound.
Also, I take it you are aware that the SLOPE function will only consider rows for which both the known_ys and the known_xs are numeric? For example, assuming that the above resolved to:
known_ys
known_xs
14
FALSE
53
FALSE
FALSE
27
FALSE
FALSE
16
63
58
90
FALSE
FALSE
3
FALSE
80
85
25
40
then SLOPE would ignore everything apart from the the 5th, 6th, 9th and 10th pairs, effectively calculating over the following reduced array:
known_ys
known_xs
16
63
58
90
80
85
25
40

Excel automatically charting for concrete range of data

Excel masters, I need help about charting in excel. I have a table with data ("WEEK number", "date of start", "some data") and chart! the problem is: I need when I add new week data the chart should automatically update but I need to see only 53 weeks. For example: if I add week 30 I need to see data on the chart from week 30 (2018) to week 30 (2019)
Thank you for your help in advance
Week # Start Date Data
20 05-13-2018 21,866
21 05-20-2018 20,317
22 05-27-2018 18,078
23 06-03-2018 19,254
24 06-10-2018 17,990
25 06-17-2018 19,589
26 06-24-2018 22,346
27 07-01-2018 18,985
28 07-08-2018 18,482
29 07-15-2018 17,493
30 07-22-2018 21,217
31 07-29-2018 16,205
32 08-05-2018 16,534
33 08-12-2018 16,694
34 08-19-2018 18,190
35 08-26-2018 20,559
36 09-02-2018 24,503
37 09-09-2018 26,074
38 09-16-2018 24,092
39 09-23-2018 33,828
40 09-30-2018 28,979
41 10-07-2018 28,493
42 10-14-2018 30,634
43 10-21-2018 29,473
44 10-28-2018 28,202
45 11-04-2018 30,088
46 11-11-2018 36,070
47 11-18-2018 36,689
48 11-25-2018 35,509
49 12-02-2018 27,794
50 12-09-2018 27,802
51 12-16-2018 16,521
52 12-23-2018 13,786
1 12-31-2018 18,271
2 01-07-2019 27,336
3 01-14-2019 29,837
4 01-21-2019 31,464
5 01-28-2019 31,395
6 02-04-2019 31,383
7 02-11-2019 28,152
8 02-18-2019 30,795
9 02-25-2019 25,183
10 03-04-2019 28,344
11 03-11-2019 38,064
12 03-18-2019 36,815
13 03-25-2019 36,741
14 04-01-2019 35,849
15 04-08-2019 35,199
16 04-15-2019 28,407
17 04-22-2019 16,427
18 04-29-2019 29,678
19 05-06-2019 28,270
20 05-13-2019 24,046
21 05-20-2019 21,191
22 05-27-2019 21,480
23 06-03-2019 23,919
24 06-10-2019 20,532
25 06-17-2019 20,575
26 06-24-2019 19,111
27 07-01-2019 19,279
28 07-08-2019 22,265
29 07-15-2019 5,979
You can use defined names to automatically update a chart range in Excel.
You can refer to any array/range by a name in excel. There are formulas to find the specific array/range and we call them Array Formulas. One of the most common array formula is OFFSET. If you are not familiar with this formula, please google some tutorials online before continue.
In your example, let's presume Week # is in Column A, Start Date is in Column B, and Data is in Column C, and the name of the worksheet is SheetName.
In order to dynamically look up a 53-Week range in Column A, B and C using OFFSET formula, you need to find the starting point (i.e. the cell in each column corresponds to the first week of the 53-week range) .
For instance, if your latest Week # is Week #29 in Cell A63, the starting point would be Week #29 in Cell A11. One way of finding the latest week # is to find the corresponding maximum/latest date in the Start Date column, and use MATCH formula to find the row number. Such logic is translated into the following formulas:
Start Point in Column A (the Week # column) ="A"&MATCH(MAX(B:B),B:B,0)-52
Start Point in Column B (the Start Date column) ="B"&MATCH(MAX(B:B),B:B,0)-52
Start Point in Column C (the Data column) ="C"&MATCH(MAX(B:B),B:B,0)-52
Then you can find the 53-Week range in each column by referencing the relevant starting point in the OFFSET formula. Please note you need to press CSE Ctrl+Shift+Enter upon finishing entering each array formula to make it work.
For Column A (the Week # column) =OFFSET(INDIRECT("SheetName!A"&MATCH(MAX(SheetName!$B:$B),SheetName!$B:$B,0)-52),,,53)
For Column B (the Start Date column) =OFFSET(INDIRECT("SheetName!B"&MATCH(MAX(SheetName!$B:$B),SheetName!$B:$B,0)-52),,,53)
For Column C (the Data column) =OFFSET(INDIRECT("SheetName!C"&MATCH(MAX(SheetName!$B:$B),SheetName!$B:$B,0)-52),,,53)
The next step is to create three names for the above ranges. Press Ctrl+F3 to open the Name Manager in excel, and manually create the names and copy and paste the above formulas in the 'Refers to:' field.
Then you can create a chart from the existing data, and replace the hard-coded series values with the range names to make it dynamic as shown below:
Click anywhere within the chart, then you will see the Chart Design tab shown on top of the the ribbon of your excel. Go to Select Data and Edit the Data and Date value as shown below:
I have created a sample bar chart below showing the data for the most recent 53 weeks. Please note I have added 5 weeks' of new data to test the result, and I have put the Week # as the data label for the bar chart instead of the actual dollar value.
Lastly, you can refer to the following article for more clarifications.
How to use defined names to automatically update a chart range in Excel

Find all rows that contains 4 specific values?

I am using excel and I have a table of numbers with 6 columns from A to F and more than 1000 rows. For example, from my table,
4 17 37 38 47 53
8 43 54 55 56 60
4 18 21 25 38 57
15 25 37 38 58 59
4 16 19 20 27 43
18 32 47 50 54 56
i want to find if there is at least a row (it must be a row!) that contains the numbers 16 19 20 27. From this example, there is a match, but i don't know how to make a search or formula using four diferent numbers.
I feel like I need to use the match function but can't quite figure it out and I'm not sure about it. Does anyone know how to do this?
Thanks!
This should work:
=IF(AND(OR(A1=16,B1=16,C1=16,D1=16,E1=16,F1=16),OR(A1=19,B1=19,C1=19,D1=19,E1=19,F1=19),OR(A1=20,B1=20,C1=20,D1=20,E1=20,F1=20),OR(A1=27,B1=27,C1=27,D1=27,E1=27,F1=27)),"Yes","No")
Put it in a new column in the table. It will return a Yes if the row contains all 4 values, and a No otherwise. You can then filter the new column of Yes/No to search for a row with Yes
I put the four values you are seeking in I1:L1 and the array of data to be searched in A1:F#. Then in column G create a helper column that concatenates A:F into a delimited string. The formula in G1 is:
=":"&A1&":"&B1&":"&C1&":"&D1&":"&E1&":"&F1&":"
where I've used ":" for the delimiter (you can use any char that's not in your data).
The result in G1 is:
:4:17:37:38:47:53:
Now in H1 use this formula to search:
=NOT(ISERR(FIND(":"&$I$1&":",G1)*FIND(":"&$J$1&":",G1)*FIND(":"&$K$1&":",G1)*FIND(":"&$L$1&":",G1)))
Each FIND will return an INT if the value (with leading and trailing delimiters) is found and #VALUE! otherwise. So the product will be an INT if all values are found and #VALUE! otherwise. Wrapping the FINDs inside an ISERR makes the result prettier (TRUE/FALSE instead of #VALUE!), and inverting with NOT returns TRUE when all 4 values are found and FALSE otherwise.
Hope that helps.
Here's another way --- more elegant (no helper column). As before, I put the four values you are seeking in I1:L1 and the array of data to be searched in A1:F#. Then in column G use this ARRAY formula (CTRL-SHIFT-ENTER):
=NOT(OR(PRODUCT(A1:F1-$I$1)<>0,PRODUCT(A1:F1-$J$1)<>0,PRODUCT(A1:F1-$K$1)<>0,PRODUCT(A1:F1-$L$1)<>0))
Each PRODUCT term checks for the existence of one value and returns 0 when the value is found and a non-zero value otherwise. The results of each of the four PRODUCT terms is tested with <>0 which will return TRUE if a value is not found. Then OR with return TRUE if one or more values are not found and FALSE if all are found. That result is wrapped in a NOT so that the function result is TRUE when all four values are found.

Create a formula that returns a minimum date from a range based on cell values in another column

I am looking for a formula that will return the earliest date from a column, based on the contents of values in other cells. (Actually I want a Min and Max date, but am assuming the Max will be identical to any Min solution )I know I can return the date I want just by using MIN and specifying the range of cells I want, but I ideally want the formula to be dynamic. I have looked around and believe I possibly need to use a combination of index and match, but cant find any examples that use Min and Max. I have considered using dynamic named ranges to define my task groups, but that would mean having to define a static number of task groups, and there could be many task groups.
The sheet below shos some sample date on the left of the workbook, with the summary data on the right. The "hidden worker column" was an idea I had that I though might make the solution easier. So I want the summary data on the right to use either column A, or column B if its easier, to display the min and max dates based on the section number in column F - Is this possible without VBA?
#mthierer's link is good. If you wanted to remove the need to add a "helper column", you could try (data in A1:C10; summary table in E1:G2):
{=MIN(IF(ROUNDDOWN($A$1:$A$10, 0)=$E1, $B$1:$B$10))} (or {=MAX(...)} with $C$1:$C$10)
Note that you have to enter the formula as an array formula with CtrlShiftEnter.
Data (A1:C10):
1 23 57
1.1 42 91
1.2 35 100
1.3 39 80
1.4 28 51
1.5 30 96
2 33 52
2.1 11 73
2.2 48 80
2.3 16 59
Summary Results (E1:G2):
1 23 100
2 11 80

Resources