In the below image, I use the following formula to get the New York scores of students (the specific version pulls Laura's NY score of 36:
=INDEX(A:B,MIN(IF((ROW(A:A)>MATCH("New York",A:A,0))*(LEFT(A:A, 5)="Laura"),ROW(A:A),"")),2)
However, the one amendment I want to make is to say if the name cell ends in (Base), the score that is pulled should be 100 minus the value in column B (i.e. it would show 64). Where do I put the logic IF and RIGHT logic within the formula?
Appreciate any help.
Try,
=ABS(INDEX(B:B, AGGREGATE(15, 7, ROW(INDEX(A:A, MATCH("new york", A:A, 0)):INDEX(A:A, MATCH(1E+99, B:B)))/(LEFT(INDEX(A:A, MATCH("new york", A:A, 0)):INDEX(A:A, MATCH(1E+99, B:B)), LEN("laura"))="laura"), 1))-(RIGHT(INDEX(A:A, AGGREGATE(15, 7, ROW(INDEX(A:A, MATCH("new york", A:A, 0)):INDEX(A:A, MATCH(1E+99, B:B)))/(LEFT(INDEX(A:A, MATCH("new york", A:A, 0)):INDEX(A:A, MATCH(1E+99, B:B)), LEN("laura"))="laura"), 1)), LEN("(base)")) = "(base)")*100)
Related
If we do not use VBA, any methods can be used to split the following cell in excel?
Please advise the methods for splitting text "ParisFrancePeter" to 3 separate words "Paris" "France" and "Peter".
'first word
=REPLACE(A1, AGGREGATE(15, 7, ROW(2:99)/(CODE(MID(A1, ROW(2:99), 1))<=90), 1), LEN(A1), "")
'middle word
=MID(A1, AGGREGATE(15, 7, ROW(2:99)/(CODE(MID(A1, ROW(2:99), 1))<=90), 1), LEN(A1)-AGGREGATE(14, 7, ROW(2:99)/(CODE(MID(A1, ROW(2:99), 1))<=90), 1)+2)
'last word
=REPLACE(A1, 1, AGGREGATE(14, 7, ROW(2:99)/(CODE(MID(A1, ROW(2:99), 1))<=90), 1)-1, "")
If you also have other than three words to split, then, with your original string in A1, enter the formula below in B1 and fill right as far as required:
=IFERROR(MID($A1,IFERROR(AGGREGATE(15,6,1/((CODE(MID($A1,seq,1))>=65)*(CODE(MID($A1,seq,1))<=90))*(seq),COLUMNS($A:A)),""),IF(IFERROR(AGGREGATE(15,6,1/((CODE(MID($A1,seq,1))>=65)*(CODE(MID($A1,seq,1))<=90))*(seq),COLUMNS($A:B)),"")="",99,IFERROR(AGGREGATE(15,6,1/((CODE(MID($A1,seq,1))>=65)*(CODE(MID($A1,seq,1))<=90))*(seq),COLUMNS($A:B)),"")-IFERROR(AGGREGATE(15,6,1/((CODE(MID($A1,seq,1))>=65)*(CODE(MID($A1,seq,1))<=90))*(seq),COLUMNS($A:A)),""))),"")
where seq is a Named Formula that generates an array of numbers {1...255} and refers to:
=ROW(INDEX($1:$65535,1,1):INDEX($1:$65535,255,1))
The code will return the starting point of each Upper Case letter, and then uses the MID function to return the substring between that and the next upper case letter. Then there is some error checking.
I currently have generation data over half-hourly time intervals. However there are about 70 entries for each half hour. What I want to do is make a column that aggregates all the generation for each time interval.
Currently my approach is this =SUM(D2:D71) and then in the next cell SUM(D72:D144) etc. Surely there must be a more efficient way of doing this?
Thanks
Hi you can create a pivot table
Ctrl + a your data - Insert - create pivot table
put the interval number in the [Rows] field and put the Energy generated in [Values]
SUMIFS would seem to be useful.
=sumifs(d:d, c:c, ">="&a2+time(8, 0, 0), c:c, "<"&a2+time(8, 30, 0)
=sumifs(d:d, c:c, ">="&a2+time(8, 30, 0), c:c, "<"&a2+time(9, 0, 0)
=sumifs(d:d, c:c, ">="&a2+time(9, 0, 0), c:c, "<"&a2+time(9, 30, 0)
=sumifs(d:d, c:c, ">="&a2+time(9, 30, 0), c:c, "<"&a2+time(10, 0, 0)
'etc ...
The time sequence could likely be resolved with a ROW() function that advances when filled down.
If you copied column C to a new unused column (e.g. column H) and removed duplicates then this should suffice.
=sumifs(d:d, h:h, ">="h2, h:h, "<"&h2+time(0, 30, 0)
I need a little help, I have an Excel book with a long list of customers and in the adjacent cell is ether a 1 or 0 depending if the customer has ordered in the past month.
How can I split this list into 2 lists on another page one been ordered in the past month and the other not ordered,
Im unable to use Macros due to security levels on the PC.
Thanks
Try,
'for ones
=INDEX(A:A, AGGREGATE(15, 7, ROW(B$2:INDEX(B:B, MATCH(1E+99, B:B)))/(B$2:INDEX(B:B, MATCH(1E+99, B:B))=1), ROW(1:1)))
'for zeroes
=INDEX(A:A, AGGREGATE(15, 7, ROW(B$2:INDEX(B:B, MATCH(1E+99, B:B)))/(B$2:INDEX(B:B, MATCH(1E+99, B:B))=0), ROW(1:1)))
Of course, you will have to modify to suit the different worksheet.
See the image below. Using array formulas (Ctrl+Shift+Enter) I entered this into D2:D8:
=IFERROR(INDEX(A2:A8,SMALL(IF(B2:B8,ROW(A2:A8)-ROW(A1)),ROW(A2:A8)-ROW(A1))),"")
and this into E2:E8:
=IFERROR(INDEX(A2:A8,SMALL(IF(1-B2:B8,ROW(A2:A8)-ROW(A1)),ROW(A2:A8)-ROW(A1))),"")
Explanation
This is how Excel will calculate the first formula:
=IFERROR(INDEX(A2:A8,SMALL(IF(B2:B8,ROW(A2:A8)-ROW(A1)),ROW(A2:A8)-ROW(A1))),"")
=IFERROR(INDEX(A2:A8,SMALL(IF({1;0;1;0;0;0;1},{2;3;4;5;6;7;8}-1),{2;3;4;5;6;7;8}-1)),"")
=IFERROR(INDEX(A2:A8,SMALL(IF({1;0;1;0;0;0;1},{1;2;3;4;5;6;7}),{1;2;3;4;5;6;7})),"")
=IFERROR(INDEX(A2:A8,SMALL({1;FALSE;3;FALSE;FALSE;FALSE;7},{1;2;3;4;5;6;7})),"")
Since the second argument of SMALL is an array, it will find the 1st, 2nd, 3rd, etc. value, ignoring FALSE (it will return #NUM! for the 4th through 7th value).
=IFERROR(INDEX(A2:A8,{1;3;7;#NUM!;#NUM!;#NUM!;#NUM!}),"")
=IFERROR({"A";"C";"G";#NUM!;#NUM!;#NUM!;#NUM!},"")
={"A";"C";"G";"";"";"";""}
I am looking for a formula that gives me the closest value in a specific row in a table and another formula that gives me the column number where the value was found.
Thank you,
Debby
Fill these two array formulas into b16:b17 finishing each with ctr+shift+enter.
=AGGREGATE(15, 6, (INDEX(B4:I11, MATCH(B14, A4:A11, 0), 0))/(ABS(INDEX(B4:I11, MATCH(B14, A4:A11, 0), 0)-B15)=MIN(ABS(INDEX(B4:I11, MATCH(B14, A4:A11, 0), 0)-B15))), 1)
=AGGREGATE(15, 6, COLUMN(A:H)/(ABS(INDEX(B4:I11, MATCH(B14, A4:A11, 0), 0)-B15)=MIN(ABS(INDEX(B4:I11, MATCH(B14, A4:A11, 0), 0)-B15))), 1)
I have a database of about 100 columns with similar data to from COL A to COL H.
I use the formula in COL J to search in a column for two consecutive rows with "-" and mark the second row as a double as you can see on J16 and J32.
This method is time consuming because I do often search for different columns and have to change the formula each time.
I would like something like N3. Entering the column ID and when I hit enter I will get automatically the count of rows with two consecutive "-" and also I would like to increase to search for triples and quadruples.
Any help will be appreciate.
Formula on J2:
=IF(AND(OR(F2=F1,F1="-"),F2="-"),"double","")
image here
In N5 to count doubles,
=COUNTIFS(INDEX(A:H, 2, CODE(UPPER(N3))-64):INDEX(A:H, MATCH("zzz", INDEX(A:H, , CODE(UPPER(N3))-64)), CODE(UPPER(N3))-64), "-",
INDEX(A:H, 3, CODE(UPPER(N3))-64):INDEX(A:H, MATCH("zzz", INDEX(A:H, , CODE(UPPER(N3))-64))+1, CODE(UPPER(N3))-64), "-")
This is the dynamic equivalent of using,
=COUNTIFS(G2:G20, "-", G3:G21, "-")
In N6 to count triples,
=COUNTIFS(INDEX(A:H, 2, CODE(UPPER(N3))-64):INDEX(A:H, MATCH("zzz", INDEX(A:H, , CODE(UPPER(N3))-64)), CODE(UPPER(N3))-64), "-",
INDEX(A:H, 3, CODE(UPPER(N3))-64):INDEX(A:H, MATCH("zzz", INDEX(A:H, , CODE(UPPER(N3))-64))+1, CODE(UPPER(N3))-64), "-",
INDEX(A:H, 4, CODE(UPPER(N3))-64):INDEX(A:H, MATCH("zzz", INDEX(A:H, , CODE(UPPER(N3))-64))+2, CODE(UPPER(N3))-64), "-")
In N7 to count quads,
=COUNTIFS(INDEX(A:H, 2, CODE(UPPER(N3))-64):INDEX(A:H, MATCH("zzz", INDEX(A:H, , CODE(UPPER(N3))-64)), CODE(UPPER(N3))-64), "-",
INDEX(A:H, 3, CODE(UPPER(N3))-64):INDEX(A:H, MATCH("zzz", INDEX(A:H, , CODE(UPPER(N3))-64))+1, CODE(UPPER(N3))-64), "-",
INDEX(A:H, 4, CODE(UPPER(N3))-64):INDEX(A:H, MATCH("zzz", INDEX(A:H, , CODE(UPPER(N3))-64))+2, CODE(UPPER(N3))-64), "-",
INDEX(A:H, 5, CODE(UPPER(N3))-64):INDEX(A:H, MATCH("zzz", INDEX(A:H, , CODE(UPPER(N3))-64))+3, CODE(UPPER(N3))-64), "-")
If you require quints, you should be able to get the idea from those.
You want to use your column entry in cell N3. You can do this using the indirect function. Just change the formula in cell J2 from this:
=IF(AND(OR(F2=F1,F1="-"),F2="-"),"double","")
...to this:
=IF(AND(INDIRECT(N$3&ROW())="-",INDIRECT(N$3&ROW()-1)="-"),"double","")
You can catch triples and quadruples in the same way, try this formula ...it'll only work from row 4 onwards, and the results may feel messy, depending on what you need:
=IF(AND(INDIRECT(N$3&ROW()-1)="-",INDIRECT(N$3&ROW())="-"),IF(AND(INDIRECT(N$3&ROW()-2)="-",INDIRECT(N$3&ROW()-1)="-",INDIRECT(N$3&ROW())="-"),IF(AND(INDIRECT(N$3&ROW()-3)="-",INDIRECT(N$3&ROW()-2)="-",INDIRECT(N$3&ROW()-1)="-",INDIRECT(N$3&ROW())="-"),"quadruple","triple"),"double"),"")
With reference to the figure at the bottom, there are:
Helper cells N1:N2 and N9:N19, whose contents helps the formulas you need being more concise.
See below the explanation and formulas for these.
Cells with the formulas you need, using SUMPRODUCT combined with some form of dynamic referencing.
Cells N5:N7
give the result you want, but with fixed references. These are
N5: =SUMPRODUCT(($G$2:$G$21="-")*($G$3:$G$22="-"))
N6: =SUMPRODUCT(($G$2:$G$20="-")*($G$3:$G$21="-")*($G$4:$G$22="-"))
N7: =SUMPRODUCT(($G$2:$G$19="-")*($G$3:$G$20="-")*($G$4:$G$21="-")*($G$5:$G$22="-"))
You can grasp the systematics.
Cells O5:O7
give the same result, using INDIRECT instead of fixed references (option #1 for what you need, see this). These are
O5: =SUMPRODUCT(
(INDIRECT($N$3&$N$9):INDIRECT($N$3&($N$10-1))="-")
*(INDIRECT($N$3&($N$9+1)):INDIRECT($N$3&$N$10)="-")
)
O6: =SUMPRODUCT(
(INDIRECT($N$3&$N$9):INDIRECT($N$3&($N$10-2))="-")
*(INDIRECT($N$3&($N$9+1)):INDIRECT($N$3&($N$10-1))="-")
*(INDIRECT($N$3&($N$9+2)):INDIRECT($N$3&$N$10)="-")
)
You can grasp the systematics and write the formula for cell O7.
Cells P5:P7
give the same result, using OFFSET instead of fixed references (option #2 for what you need, see this, this, or this). These are
P5: =SUMPRODUCT(
(OFFSET($A$1,$N$12,$N$14):OFFSET($A$1,$N$13-1,$N$14)="-")
*(OFFSET($A$1,$N$12+1,$N$14):OFFSET($A$1,$N$13,$N$14)="-")
)
P6: =SUMPRODUCT(
(OFFSET($A$1,$N$12,$N$14):OFFSET($A$1,$N$13-2,$N$14)="-")
*(OFFSET($A$1,$N$12+1,$N$14):OFFSET($A$1,$N$13-1,$N$14)="-")
*(OFFSET($A$1,$N$12+2,$N$14):OFFSET($A$1,$N$13,$N$14)="-")
)
You can grasp the systematics and write the formula for cell P7.
There are likely other options combining INDIRECT and OFFSET (see this). An option using INDEX (although likely not the only variant) was covered by Jeeped.
Note on helper cells:
I suggest having helper cells, and this applies to other answers posted here as well.
Of course you may move these cells around, adjusting the corresponding formulas.
The only non trivial formula here is for cell N11, =COLUMN(INDIRECT($N$3&"1")) (see this or this).
Cell N19 may be useful if you are going to use INDEX.