In the screenshot provided, I am trying to extract all of the flow data into one column by itself. I got started using the INDEX function, but I believe I am missing something. In the screenshot, cell G2 should contain the value "998", which it does. Starting from cell C8, flow values occur every 14 rows in that column, so I want to write a function that when I copy and paste starts looking at cell C8 and returns the value every 14 rows. What I have so far is this:
=INDEX(C8:C354528, ROW(C1)+14)
This is close, because it does return me the value "998", but going forward, it basically moves my array selection down by one and the counts 14 rows...not what I want.
As an example, the next two values after "1000" should be, 998 and 992.
What am I missing here?
If you can use a second helper column, you can use this Array formula to find such rows. Note that this has a benefit in that your rows can be in any order - you aren't relying on the fact that "Flow" data is exactly X rows apart.
In Column I, let's say, in I1, you can put this:
=IFERROR(SEARCH(" Flow ",$B1),"").
Then, where you want to keep your Flow numbers, you can use this array formula:
=INDEX($C$1:$C$100,SMALL(IF($I$1:$I$100<>"",ROW($C$1:$C$100)-ROW($C$1)+1),ROWS($C$1:C1)))
(enter using CTRL+SHIFT+ENTER)
Use this:
=INDEX(C:C,8+(ROW(1:1)-1)*14)
And copy/drag down.
As stated in the comments OFFSET is volatile and should be avoided when possible. INDEX() is not volatile.
Related
It's probably a simple problem, but I did not even know the keywords to google it ;/. Let's say I have this data :
Now I also have this litle formula:
If I know drag the C cell to the right, Excel will attempt the following caluclation:
=2+B1
What I want him to do is to attempt this calculation
=2+A2
Of course the easiest solution would be to store my initial data in one row instead of 1 column, but it is really inconvenient for me. Thanks for any help
You can use the indirect() method to reference a cell by it's "String identifier", i.e. "A3". When filling out to the right, use CONCATENATE() and COLUMN() to create your String identifiers {A1,A2,A3,A4,A5...} as required:
=2+INDIRECT(CONCATENATE("A";COLUMN()-2))
This will result in the following:
Side-Node: If you want this for some x/y-Grid-Generation, you can also be lazy,
and just insert =COLUMN() for every cell from "A1 - Z1" and ROW() for every cell from "A2 - A24".
(Or even avoid these at all and directly perform your actual calculation by using column() and row() as replacement for your x/y.
You may try using a combination of the INDIRECT and COLUMN functions:
=2+INDIRECT("A"&(COLUMN()-2))
You would paste the above formula into cell C1, and then drag across to the right however many columns/rows you wanted to cover.
This would result in the following:
This works because COLUMN()-2 returns 1 for the C column, 2 for the D column, and so on. Therefore, the formula will be calling INDIRECT on A1, A2, etc. for column C, D, and so on.
In general, if you want relative references to move down as cells are dragged to the right, you can use this:
Instead of:
= 2+A1
Do:
= 2+INDEX($A:$A,COLUMN()+<offset>)
Where <offset> is whatever offset you need. The offset will change depending on which column the starting formula is located in.
INDEX should be preferred over INDIRECT because INDIRECT is volatile (must recalculate after any change to the workbook) but INDEX is not (only recalculated when one of the inputs the formula, in this case $A:$A, changes).
I am trying to produce a count of the number of times different strings come up in an Excel table. An example table, currently in SHEET1, would be this:
I have another table in another spreadsheet where I want to indicate, for each letter on the left in Table 1, how many entries for "za", "zc" or "zd" come up on the right. However, I would only like to only consider one entry of each.
The end result, on row B of SHEET2, would have to be something like this:
At the moment I am using a combination of SUM and COUNTIFS to do the job.
More specifically, applied to the example, I am using the following formula:
=SUM(COUNTIFS(Sheet1!A1:A18,Sheet2!$A1,Sheet1!B1:B18,{"za","zc","zd"}))
The formula is doing some of what is intended. However, it is not counting each entry just one time. Instead, its is counting, for each letter on the left, every entry of "za","zc" or "zd". The table that the formula is returning is as follows:
How can I change the formula so that it does what I intend?
Thank you.
My initial thought would be:
=SUM(MIN (1,COUNTIFS(Sheet1!A1:A18,Sheet2!$A1,Sheet1!B1:B18,{"za","zc","zd"}))
but I’m not where I can test if the MIN will apply properly to the COUNTIFS array of results. ;-)
EDITED: The MIN function is taking minimum of 1 or all of the items in the COUNTIFS array, rather than minimum of 1 and each item in the COUNTIFS array, which is what I was afraid of. Using
=MIN(COUNTIFS(Sheet1!A$1:A$18,Sheet2!$A1,Sheet1!B$1:B$18,"za"),1)+MIN(COUNTIFS(Sheet1!A$1:A$18,Sheet2!$A1,Sheet1!B$1:B$18,"zc"),1)+MIN(COUNTIFS(Sheet1!A$1:A$18,Sheet2!$A1,Sheet1!B$1:B$18,"zd"),1)
will gain the desired results. It is a little clunky, but simpler than an array formula. If you want an array formula, you can use:
=SUM(FREQUENCY(IFERROR(MATCH({"za","zc","zd"},(IF(Sheet1!$A$1:$A$18=$A5,Sheet1!$B$1:$B$18)),0),""),IFERROR(MATCH({"za","zc","zd"},(IF(Sheet1!$A$1:$A$18=$A5,Sheet1!$B$1:$B$18)),0),"")))
This uses the FREQUENCY function to take a set of values and see how many items in another set of values fall within each of the data ranges. Since you need text instead of numbers, we use the MATCH function to find out the first time the value occurs in your list, returning "" with the IFERROR function if it doesn't. (We only need the first occurrence since you don't want to know how many occurrences there are). Since it is text, we use the same input for both arguments for FREQUENCY.
Therefore, if you need to change the values you are looking for or the ranges in which you are searching, make sure to change both! Alternately, you could list the values out somewhere, say in F1:F3, and make a named range for this, another one for A1:A18, and another for B1:B18. Your formula would then look something like this:
=SUM(FREQUENCY(IFERROR(MATCH(SearchValues,(IF(colA=$A2,colB)),0),""),IFERROR(MATCH(SearchValues,(IF(colA=$A2,colB)),0),"")))
Then you need only change your named range definitions and your formulas would update. :-)
NOTE: Since this is an array formula, you must close out of the cell by pressing CTRL+SHIFT+ENTER rather than only ENTER. When you look at the formula bar, you should see
{=SUM(FREQUENCY(IFERROR(MATCH(SearchValues,(IF(colA=$A2,colB)),0),""),IFERROR(MATCH(SearchValues,(IF(colA=$A2,colB)),0),"")))}
It does NOT work to enter the curly braces yourself. ;-)
You can use this formula at B1 and fill down:
B1:
=SUMPRODUCT(((Sheet1!$A$1:$A$18=A1)*(Sheet1!$B$1:$B$18= {"za","zc","zd"}))/
COUNTIFS(Sheet1!$A$1:$A$18,Sheet1!$A$1:$A$18,Sheet1!$B$1:$B$18,Sheet1!$B$1:$B$18))
Suppose that we have two columns including a million rows
like this:
What is the right formula or VBA to make another arranged table like this?
For a pure Excel solution try this.
First you need to add a helper column. This just returns TRUE on a header row or FALSE otherwise. This isn't strictly necessary, but it will make the rest of the formulas a little simpler. In the sample you provided above, type this into cell C1:
=IF(A1=B1,TRUE,FALSE)
Now enter this is cell D1:
=IF(AND(C1,NOT(C2)),A2,"")
What this does is check if the current row is a header but not the next, and copies the first cell of the next row if it is, or returns a blank string if it isn't.
Each subsequent cell follows the same pattern, but it first checks if the previous cell is blank. Enter this function into cell E1:
=IF(D1="","",IF(AND(C1,NOT(C3)),A3,""))
Now you just need to copy this pattern outfor another 10 cells. Unfortunately copy-and-paste won't work as you need to increment A3 and C3 downwards, while copy-and-paste with increment them to the right. So, from E1, we get:
F1: =IF(E1="","",IF(AND(C1,NOT(C4)),A4,""))
G1: =IF(F1="","",IF(AND(C1,NOT(C5)),A5,""))
.
.
.
O1: =IF(N1="","",IF(AND(C1,NOT(C13)),A13,""))
Now copy those cells to the bottom of the data set and you should get the results you're after. Here's an example:
Note the extra TRUE in cell C21 so that the last calculation terminates correctly.
However, if you really have a million rows in your data set, I would question the wisdom of using Excel at all. Depending on your circumstances and resources, you may be better off keeping the data in a text file and processing it with a proper scripting language.
Problem Solved in excelforum by JohnTopley here:
http://www.excelforum.com/excel-formulas-and-functions/1174447-interrupted-transpose.html
I am using a formula in Excel 2010 to display the individual with the most wins, as below:
IF($P$3="Most wins",SUM(LARGE(Wins,{1})),"FALSE")
where wins represents an array of an indefinite number of individuals.
However I would like to be able to autofill this, or similar, such that the next row displays the following:
IF($P$3="Most wins",SUM(LARGE(Wins,{2})),"FALSE")
Unfortunately I can't get the value inside the curly brackets to increment, which is causing no end off issues when the formula is going to be dragged down beyond 1,000 rows.
Is this possible, or am I using the wrong method?
=IF($P$3="Most wins",SUM(LARGE(Wins,ROW(A1))),"FALSE")
Place that in the top of your column and copy it down. As you do, the cell reference for A1 will change from A1 to A2 to A3, etc. The ROW function returns the number of the row of the cell reference.
Alternatively as pointed out in Darren's comment, you could also use ROW()-2 if you data is starting in the second row. This has the advantage if you ver deleted the 1 row or column, you will not screw up your cell references.
I am trying to fetch dates from sheet1 with common ID (there are multiple occurrences in sheet1) using an array formula in a cell (then dragging it to the right side to have all the dates belong to specific ID):
=IF(COLUMNS($E2:E2)<=$D2,INDEX(Sheet1!$B$2:$B$13,SMALL(IF(Sheet1!$A$2:$A$13=Sheet2!$A2,
ROW(Sheet1!$A$2:$A$13)-ROW(Sheet1!$A$2)+1),COLUMNS($E2:E2))),"")
But, whenever I try to insert one column (for counting purposes) in b/w the columns, this formula doesn't work. I can't figure out the issue, would really appreciate the help?
Thank you.
Assuming that your first formula is in E2, and that the cells in row 2 of any newly-inserted columns will always be blank, replace the two instances of:
COLUMNS($E2:E2)
in your formula in E2 with:
COUNT(1/LEN($D2:D2))
As a way of explanation, take the formula in F2, for which this part will be:
COUNT(1/LEN($D2:E2))
(The only part having changed naturally being the end range reference.)
And let's assume that 3 new columns are inserted to the left of column E, which means that E2, F2 and G2 will now be blank, H2 will contain the entry which was previously in E2, and, for the formula in I2, the above part will now be:
COUNT(1/LEN($D2:H2))
Clearly we wish this part to continue to give 2, since this cell should still represent the second of our returns.
Using LEN is a rigorous way to determine whether a cell is empty or not. Other functions are also available for this purpose, though may give incorrect results depending upon whether the blanks in that range are "genuine" blanks or the null string "" as a result of formulas in those cells.
If a cell is empty, it has a length of 0. Hence, in this example, the above resolves to:
COUNT(1/{1,0,0,0,2})
(Where I've made some random assumptions about the lengths of the strings in cells D2 and H2.)
There are many ways to determine how many non-zeroes there are in an array. SUMPRODUCT would be one; I chose another, the logic being that the above becomes, after reciprocation with unity:
COUNT({1,#DIV/0!,#DIV/0!,#DIV/0!,0.5})
and, since COUNT ignores any errors in the range passed to it, the above resolves to 2, as desired.
Regards