I have a Row and the range is B2:B10 and the numbers are from 1 - 9. At random about 1/2 of those numbers will be placed in this Row and need the formula to tell me what numbers are missing. Of course, I can simply look and tell what they are but would like for the formula to let me know. When you ask this question on the Internet it gives the solution for Columns and not Rows. I know this involves an array, but haven't quite mastered that yet.
Thanks.
=TEXTJOIN(",",,IF(ISERROR(MATCH({1,2,3,4,5,6,7,8,9},B2:B10,0)),{1,2,3,4,5,6,7,8,9},"")) should work if a you need a list of numbers not included.
So, for large number it is hard to hardcode numbers in array. You may like this dynamic approach where you do not need to hardcode numbers rather you can just use SEQUENCE() function (if your Excel have it) to define how many numbers you want to check. Try-
=TEXTJOIN(",",TRUE,IF(ISERROR(MATCH(SEQUENCE(20),B2:B10,0)),SEQUENCE(20),""))
Related
my goal is to count the number of person that having different criteria to consider.
the below formula is working fine but not sure how are we going to put another criteria
=SUMPRODUCT((A5:A10000<>"")/COUNTIFS(A5:A10000,A5:A10000&""))
that formula will count duplicates as 1 but i also want to consider the date from other column
somehow like this if we are not going to consider the duplicates =countifs(startdatecolumn, 1/1/2022,enddatecolumn, 5/3/2022)
i tried to include that here COUNTIFS(A5:A10000,A5:A10000&"") like =SUMPRODUCT((A5:A10000<>"")/COUNTIFS(A5:A10000,A5:A10000&"",startdatecolumn, 1/1/2022,enddatecolumn, 5/3/2022) but its not working
The reciprocal SUMPRODUCT/COUNTIFS is incredibly inefficient. Much better is:
=SUM(IF(FREQUENCY(IF(A5:A10000<>"",IF(B5:B10000=DATEVALUE("1/1/2022"),IF(C5:C10000=DATEVALUE("5/3/2022"),MATCH(A5:A10000,A5:A10000,0)))),ROW(A5:A10000)-MIN(ROW(A5:A10000))+1),1))
where I've assumed that B5:B10000 and C5:C10000 contain yout start and end dates respectively.
Obviously there are even more efficient set-ups if you have O365.
I want to make a table that, in its final column, counts the number of numbers such that the row is larger than the other row. However, since the sample size for me is rather large, I want an excel formula to do this for me.
I have tried using sum, if, sumif, sumifs commands, but none seems to work (at least I can't get it to work). Any help would be appreciated.
Here is a small sample:
You can do =SUM(--(row_2_range>row_1_range)).
For example:
EDIT: to account for blanks and non-numeric data, you can use something like
=SUM(--(IF(ISNUMBER(G3:I3),G3:I3,0)>IF(ISNUMBER(G2:I2), G2:I2,0)))
You may try SUMPRODUCT()
=SUMPRODUCT(--(A1:F1>A2:F2))
In G2 cell =SUMPRODUCT(--(A2:F2>A1:F1)).
So, I have an Excel-file with two sheets. The first sheet contains 7 Columns of different values.
The second sheet contains a list of special customer prices.
What i want to do, is basicly search for the value given in e.g. cell A2, in Sheet2!A:A. If i were to find this value (it's a text value), I want to return the value located in that spesific row containing the value searched for, only 3 colums to the right.
I've done a lot of experiments, but really can't get INDEX and MATCH to do the work properly for me. Anyh suggestions?
Feel free to ask for more information, as I know I can be a challange to understand..
Best regards
try offset() and match(), offset(reference,rows,cols). use match to find the number of rows or columns to move from the reference point.
Using OFFSET is against almost all best practice guides. It is a volatile function, meaning it should be avoided at all costs. Use INDEX+MATCH instead. It can do all the same stuff but has much better performance.
=INDEX(column holding the value you want to return, match to find row #, 1)
=MATCH(value you are looking for, column you are searching in, 0 means exact match)
Result:
=INDEX(Sheet2!$D$2:$D$10,MATCH(A2,Sheet2!$A$2:$A$10,0),1)
I believe the function you are looking for is a vlookup. Try this:
=vlookup(A2, Sheet2!A:D, 4, 0)
Regards,
Windyvation
I find myself doing a lot of operations on tables where I am not sure about entry count.
I simply guess that it should be lower than 100 and just do =SUM(A1:A100). Now if I have only 2 entries, all the other rows are useless for other things.
How can I solve this problem? Maybe I can automatically detect continuous values without an empty row in between or something?
I am not about performance. If I use 100 rows for some formula just to be safe in the future but only 3 rows have values present I just wasted a lot of spreadsheet space making it harder to use and read.
EDIT
To explain what I mean by saying 'waste of space'.
I don't know how many name:value pairs I will have. Maybe 5 maybe 100. So in this case I have 3 entered but 5 empty columns. That means I have wasted 2 columns of space. When I want to be sure my calculations will handle a lot of values, I just do like =SUM(A2:A100) and leave it like that but then it's impossible to place another attributes or more values.
You can use =CAUNTA() function.
COUNTA
I'm still not convinced how one could 'waste spreadsheet space' and I would recommend using simply =SUM(A:A) in such a case.
If you must sum up to the very last cell in column A, then maybe this formula would suit you:
=SUM(A1:INDEX(A:A,MATCH(9^99,A:A)))
This formula will ignore any blanks if any and count down to the last value.
Another possible (and maybe simpler) formula is with SUMIF:
=SUMIF(A:A, "<>0")
Since blanks are considered as 0, they won't get summed, but as I said, I find it much simpler to just use SUM(A:A) since blanks are zeros anyway.
I have a SUM array formula that has multiple nested IF statements, making it very inefficient. My formula spans over 500 rows, but here is a simple version of it:
{=SUM(IF(IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17>0,
IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17,0))}
As you can see, the first half of the formula checks where the array is greater than zero, and if they are, it sums those in the second part of the formula.
You will notice that the same IF statement is repeated in there twice, which to me is inefficient, but is the only way I could get the correct answer.
The example data I have is as follows:
Sample Data in spreadsheet http://clients.estatemaster.net/SecureClientSite/Download/TempFiles/example.jpg
The answer should be 350 in this instance using the formula I mentioned above.
If I tried to put in a MAX statement within the array, therefore removing the test to find where it was greater than zero, so it was like this:
{=SUM(MAX(IF(B2:B6>B8:B12,B2:B6,B8:B12)-B14:B18,0))}
However, it seems like it only calculates the first row of data in each range, and it gave me the wrong answer of 70.
Does anyone know a away that I can reduce the size of the formula or make it more efficient by not needing to repeat an IF statement in there?
UPDATE
Jimmy
The MAX formula you suggested didnt actually work for all scenarios.
If i changed my sample data in rows 1 to 5 as below (showing that some of the numbers are greater than their respective cells in rows 7 to 11, while some of the numbers are lower)
Sample Data in spreadsheet http://clients.estatemaster.net/SecureClientSite/Download/TempFiles/example2.jpg
The correct answer im trying to achive is 310, however you suggested MAX formula gives an incorrect answer of 275.
Im guessing the formula needs to be an array function to give the correct answer.
Any other suggestions?
=MAX( MAX( sum(A1:A5), sum(A7:A11) ) - sum(A13:A17), 0)
A more calculation-efficient (and especially re-calculation efficient) way is to use helper columns instead of array formulae:
C1: =MAX(A1,A7)-A13
D1: =IF(C1>0,C1,0)
copy both these down 5 rows
E1: =SUM(D1:D5)
Excel will then only recalculate the formulae dependent on any changed value, rather than having to calculate all the virtual columns implied by the array formula every time any single number changes. And its doing less calculations even if you change all the numbers.
You may want to look into the VB Macro editor. In the Tools Menu, go to Macros and select Visual basic Editor. This gives a whole programming environment where you can write your own function.
VB is a simple programming language and google has all the guidebooks you need.
There, you can write a function like MySum() and have it do whatever math you really need it to, in a clear way written by yourself.
I pulled this off google, and it looks like a good guide to setting this all up.
http://office.microsoft.com/en-us/excel/HA011117011033.aspx
This seems to work:
{=SUM(IF(A1:A5>A7:A11,A1:A5-A13:A17,A7:A11-A13:A17))}
EDIT
- doesn't handle cases where subtraction ends up negative
This works - but is it more efficient???
{=SUM(IF(IF(A1:A5>A7:A11,A1:A5,A7:A11)>A13:A17,IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17,0))}
What about this?
=MAX(SUM(IF(A1:A5>A7:A11, A1:A5, A7:A11))-SUM(A13:A17), 0)
Edit:
Woops - Missed the throwing out negatives part. What about this? Not sure it it's faster...
=SUM((IF(A1:A5>A7:A11,IF(A1:A5>A13:A17,A1:A5,A13:A17),IF(A7:A11>A13:A17,A7:A11,A13:A17))-A13:A17))
Edit 2:
How does this perform for you?
=SUM((((A1:A5>A13:A17)+(A7:A11>A13:A17))>0)*(IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17))