have a table that i would like it to select the smallest size picture frame that could be used based on the size values,
basically return the smallest frame that would fit the image.
For example i have 4 standard sizes:
a b c
Size1 150 150
Size2 300 300
Size3 540 570
Size4 800 800
I want to have a size in another cell e.g. 290 x 300 and would like it to pick the smallest size possible to fit i.e. in this case size2.
I've followed a few guides and have the following that will print out the value if the values are exact but not if they are slightly under one of the options
=VLOOKUP($A$8,CHOOSE({1,2},$B$2:$B$5&", "&$A$2:$A$5,$C$2:$C$5),2,0)
Any helo / direction would be much appreactiated!
Thanks
Assuming order does matter (e.g. there is a difference between 500x550 and 550x500), you can use this array formula:
= INDEX($A$2:$A$5,MATCH(2,MMULT((E2:F2<=$B$2:$C$5)+0,{1;1}),0))
Note this is an array formula, so you must press Ctrl+Shift+Enter after typing this formula rather than just pressing Enter.
See below for working example.
Assuming order does not matter (e.g. there is not a difference between 500x550 and 550x500), the formula gets considerably longer because of reversing the order of the E2:F2 array. There is possibly a better way to do this but this is the easiest way I can think of to do it. Unfortunately Excel has no way of handling 3D arrays, otherwise this would be not much different from the original formula above. Anyway, here is the formula (line breaks added for readability)
= INDEX($A$2:$A$5,MIN(MATCH(2,MMULT((E2:F2<=$B$2:$C$5)+0,{1;1}),0),
MATCH(2,MMULT((INDEX(E2:F2,N(IF({1},MAX(COLUMN(E2:F2))-
COLUMN(E2:F2)+1)))<=$B$2:$C$5)+0,{1;1}),0)))
Note this is also an array formula.
See below, working example. Note how it yields the same result as above in every cell except cell G4, since again this is considering 550x500 and 500x550.
It is not clear what is in cell A8. Going by your question, I assume it must be dimensions in the format "W x H" (example: 290 x 300). If so, try:
In D2: 1
// Copy next down
In D3: D2+1
// Wherever you want it
=CONCATENATE("Size ",MIN(VLOOKUP(LEFT(A8,FIND(" ",A8)-1)+0,B2:D5,3,TRUE),VLOOKUP(RIGHT(A8,LEN(A8)-FIND("x ",A8)-1)+0,C2:D5,2,TRUE)))
Alternatively, if you split the width and height into 2 cells A8 and B8, this simpler version should do the trick:
In D2: 1
// Copy next down
In D3: D2+1
//Wherever you want it
=CONCATENATE("Size ",MIN(VLOOKUP(A8,B2:D5,3,TRUE),VLOOKUP(B8,C2:D5,2,TRUE)))
These assume the sizes all use a "Size #" naming convention. If otherwise, you could add another column at the right to equal column A, then use vlookup to identify the match, like this (again assumes "W x H" in cell A8):
In D2: 1
// Copy next down
In D3: D2+1
// Copy next down
In E2: =A2
// Wherever you want it
=VLOOKUP(MIN(VLOOKUP(LEFT(A8,FIND(" ",A8)-1)+0,B2:D5,3,TRUE),VLOOKUP(RIGHT(A8,LEN(A8)-FIND("x ",A8)-1)+0,C2:D5,2,TRUE)),D2:E5,2,FALSE)
Related
My data is regular but sparse. As an example, imagine 3 data points in A4, A14 and A24 ("a","b" and "c" respectively). I want to pull these into a table. I need it to be able to adapt to more data points (so there might be 20, might be 2, but always 10 rows apart starting in A4).
Currently, I'm handling this by using an index column (say B1:B3 with the array formula SEQUENCE(COUNTA(A:A),1,1,1), and then next to that having:
INDIRECT("R"&4+(B1-1)*10&"C1",FALSE)
but I have to drag this formula down, and I want it to update dynamically, the way the index column would.
I wanted to make this into a dynamic array by adapting the formula to:
INDIRECT("R"&4+(B1:B3-1)*10&"C1",FALSE)
or
INDIRECT("R"&4+(SEQUENCE(COUNTA(A:A),1,0,1)*10&"C1",FALSE)
It spills correctly, but both of these return arrays of #VALUE! errors instead of the expected {a,b,c}. Why would this be? Have you got any suggestions for handling this in other ways?
Try this as a cell formula
=INDEX(A:A,SEQUENCE(COUNTA(A:A),1,4,10))
for previous versions of Excel, without Sequence(), this will do
=INDEX(B1:B1000,(ROW(OFFSET($A$1,,,COUNT(B1:B1000)))-1)*10+4)
OR put the Distance (ex:10) in D3 / Start in D2 (ex:4) / Total no of Numbers in D1 (ex: D1 = Count(b1:b1000)) and write the formula:
=INDEX(B1:B1000,(ROW(OFFSET($A$1,,,$D$1))-1)*$D$3+$D$2)
up to you. (enter both as Array Formulas w ctrl+shift+enter)
B1:B1000 will contain up to 100 numbers... so adjust at will and keep small for speed
I have a list of 1s and 0s in excel row ranging from B2:K2, I want to calculate the current streak of 1's in cell M2,
example dataset where streak would be 4
1 0 1 0 1 1 1 1 0
Is there a simple way of doing this? I have tried research but not been able to find anything specific.
Any help would be much appreciated.
Here is a way of doing this with just one formula, no helper columns/rows needed:
The formula used translates to:
{=MAX(FREQUENCY(IF(B1:K1=1,COLUMN(B1:K1)),IF(B1:K1=1,0,COLUMN(B1:K1))))}
Note: It's an array formula and should be entered through CtrlShiftEnter
Assuming your data is layed out horizontally like the image below, the following two formulas should do it for you.
The first cell requires a different formula as the is no cell to the left to refer to. so a simple formula to check if the first cell is one or not is entered in B2.
=--(A1=1)
The part in the bracket will either be true or false. A quirk of excel is that if you send a true or false value through a math operation it will be converted to 1 for true and 0 for false. That is why you see the double - in front. could have also done *1, /1, +0,-0 at the end.
In B2 place the following formula and copy right as needed:
=(A2+1)*(B1=1)
Basically it adds 1 to the series, then check if the number in the sequence is 1 or 0. In the event its one, it keeps the value as it is TRUE sent through the math operator *. If it is false it set the sequence back to zero by multiplying False by the math operator *.
Alternate IF
Now the above while it works and may save a few characters is not necessarily intuitive for most. The go to option would be to use an IF function. The above formulas can be replaced with the following:
A3
=IF(A1=1,1,0)
B3 ->Copied right
=IF(B1=1,A3+1,0)
Longest streak
To get the longest streak, the highest value in your helper row is what you want. You can grab this with the following formula in an empty cell.
=MAX(2:2)
=MAX(A2,I2)
If you have no other numbers in your helper row, you can use the first formula which looks in the entire row. If there are other numbers due to calculations off to the left or right as an example, then you will want to restrict your range to you data as in the second formula.
I've put those values in cells B2 to B8.
In cell C3, I've put this formula:
=IF(AND(B3=1;B2=1);C2+1;1)
Dragging this downto C8, and then take the maximum of the C column.
I have 3 columns with percentages.
I would like to put an up or down arrow in the same cell as each percentage depending on the previous percentage.
ex: H10 = 54, L10 = 55, P10 = 50
I'd like L10 to read 55 with an up arrow and P10 to read 50 with a down arrow. Then I want to copy this formula down to the 500th rows for columns L and P.
I was able to create this for 1 row (H10, L10 and P10), but when I tried to copy it down to the other rows, it continued to reference the first row (H10, L10 and P10), . I tried to remove the "$" absolute reference and got an error message saying I cannot use relative references. How can I copy this formatting all the way down.
The fields I am using (row H, row L, row P):
Here's what I did to get around this:
I added another cell and calculated the difference between the rows, then set the formula to evaluate if the difference was negative or positive (greater than or less than 0), if it was positive there is an up arrow and if negative there is a down arrow. I made the new row small enough that only the arrow shows and the number doesn't, and I don't have borders on the two rows (the one with the number and the one with the formula) so it looks like the additional row is actually part of the row that has the true value (not the calculation).
There is one way I can think of to get a relative reference while only using what "looks like" an absolute reference.
= $A1
returns the same thing as:
= OFFSET($A$1,ROW()-ROW($A$1),0)
Notice that the formula above uses only absolute references but effectively returns a relative reference.
Try using this method to see if it will work in your case.
I want to know how many cells it take to sum N. Please see following example:
number | cells to sum of 100
100 | 1
50 | 2
20 | 3
25 | 4
15 | 4
90 | 2
10 | 2
See the last column, it find the min number of current cell + previous cells to sum of 100.
Is there a way to do so?
Thanks.
In B2, array formula**:
=IFERROR(1+ROWS(A$2:A2)-MATCH(100,MMULT(TRANSPOSE(A$2:A2),0+(ROW(A$2:A2)>=TRANSPOSE(ROW(A$2:A2)))),-1),"Not Possible")
Copy down as required.
Change the hard-coded threshold value (100 here) as required.
As way of an explanation as to the part:
MMULT(TRANSPOSE(A$2:A2),0+(ROW(A$2:A2)>=TRANSPOSE(ROW(A$2:A2))))
using the data provided and taking the version of the above from B5, i.e.:
MMULT(TRANSPOSE(A$2:A5),0+(ROW(A$2:A5)>=TRANSPOSE(ROW(A$2:A5))))
the first part of which, i.e.:
TRANSPOSE(A$2:A5)
returns:
{100,50,20,25}
and the second part of which, i.e.:
0+(ROW(A$2:A5)>=TRANSPOSE(ROW(A$2:A5)))
resolves to:
0+({2;3;4;5}>=TRANSPOSE({2;3;4;5}))
i.e.:
0+({2;3;4;5}>={2,3,4,5})
which is:
0+{TRUE,FALSE,FALSE,FALSE;TRUE,TRUE,FALSE,FALSE;TRUE,TRUE,TRUE,FALSE;TRUE,TRUE,TRUE,TRUE})
which is:
{1,0,0,0;1,1,0,0;1,1,1,0;1,1,1,1}
An understanding of matrix multiplication will tell us that:
MMULT(TRANSPOSE(A$2:A5),0+(ROW(A$2:A5)>=TRANSPOSE(ROW(A$2:A5))))
which is here:
MMULT({100,50,20,25},{1,0,0,0;1,1,0,0;1,1,1,0;1,1,1,1})
is:
{195,95,45,25}
i.e. an array whose four elements are equivalent to, respectively:
=SUM(A2:A5)
=SUM(A3:A5)
=SUM(A4:A5)
=SUM(A5:A5)
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
I did the first 3 with an excel formula:
D3>100
C4 is where your numbers start, so C4=100, C5=50 etc.
Formula is on D4, D5, D6 etc
On D4:
=IF(C4>=D3;1;"False")
On D5:
=IF(C5>=D3;1;IF(C5+C4>=D3;2;"Error"))
On D6:
=IF(C6>=D3;1;IF(C6+C5>=D3;2;IF(C6+C5+C4>=D4;3;"Error")))
You can keep doing this, just keep replacing "Error" with an longer/updated version of IF(C6+C5+C4>=D4;3.
I don't know if this is the best way, but this will achieve it.
One way to solve this is to create an NxN matrix of equations instead of just a column. An example picture is provided. Columns E through I are hidden. The last column on the right determines the number required
Theoretically, you can also hard code the equations if the number of rows needed to get to 100 is a known small number. For example, if the number of rows is always four or less, C8 would be =IFS(B8>=100,1,SUM(B7:B8)>=100,2,SUM(B6:B8)>=100,3,SUM(B5:B8)>=100,4). BTW, you'll run into sum boundary problems with this equation on the first, second, and third rows. Therefore, the first row will need to be =if(B8>=100,1,""), the second row would be =IFS(B9>=100,1,SUM(B8:B9)>100,2,TRUE,"") and so on.
I have the following columns:
A - Original values, B - Absolute values, C - sorted absolute values
(I obtain the ordered values (C) using the SMALL formula for the given range - see the link bellow)
I need to know for each ordered absolute value, if the original value was or not negative:
So in the picture the red columns I filled-in manually...
Is there a way to automatize that via a formula ?
Here is the link to the sandbox in Excel Online: http://1drv.ms/1Vu2MZ4
If the first link does not work, the same thing and formulas on Google Sheets
A partial answer, which might be enough if column E in your screenshot is what you want and column D was a helper column intended to make column E easy to compute.
The problem with ABS() is that it loses information. Instead of using that, use a function which doesn't lose information but also doesn't change the sort order and which makes it possible to recover the absolute value after sorting. One way is to leave positive numbers alone but send negative numbers to their absolute value + 0.5. For example,
In B2 enter
=IF(A2 >= 0,A2, 0.5+ABS(A2))
In C2 enter
=SMALL($B$2:$B$6,-1+ROW())
In D2 enter
=INT(C2)
To recover the absolute values. Finally, in E2 enter
=IF(C2=D2,FALSE,TRUE)
(copying all of the formulas down).
In your case and for your locale =MATCH(C2; $B$2:$B$6; 0) and = INDEX($A$2:$A$6; MATCH(C2; $B$2:$B$6; 0)) < 0 will do but beware of cases where you have the same value both negative and positive.