excel 2016 - frequency formula - data array move by one row - arrays

I have approx. 100 rows by 60 columns with numbers which I'd need to be arranged in (same) bins categories. (12 bins)
In a new sheet, I used the frequency formula to look at the first row and return in an array in a column the distribution in bins. It worked for the first row of the source data but now I'd like that when I drag the formula to the next column, the data array in the frequency formula to move to the next row of the data source and return the distribution by bins.
Is it possible, can you please help with this one? Or is there any other way I can do such a bin arrangement? Need frequencies for A, B,C etc..and would like to drag the formula to the right, if that is possible.
partial data-distributed horizontally

Use the following formula for Column U:
=FREQUENCY(INDIRECT(ADDRESS(COLUMN()-19,3) & ":" & ADDRESS(COLUMN()-19,18)),$T$3:$T$17)
and drag/copy across as required. For details on INDIRECT function see this.
Note: INDIRECT is a volatile function and hence is recalculated every time anything changes in the worksheet.
See image for results based on data provided by you.

Related

How can I drag down to multiple rows a formula which has more than 1 row in its result?

I have an extension I am getting the data from, and I am referring to that extension in a formula with result of pre determined rows but I want more than 1 row in its result and that's when I have this problem, because I want to drag the formula to multiple rows but they overlap each other, for example if I wanted 3 rows in the result of the formula starting in row 1 and then drag it down from row 1 to row 3 the formula in row 1 and 2 will show an error because they're overlapped in each other I will put a picture in how it looks...
Is there a way to specify amount of rows as a space between each formula in a way that when I drag the formula down to more rows it will adjust to the "space" I specified?
This is the formula I am using, I am also referring to another sheet as you can see so it'll be great if you can use this formula to answer my question, if I can specify the "space" using another formula that is (also it's probably obvious but the pre determined rows in the formula is the "2d").
=CRYPTOFINANCE("KRAKEN:"&'crypto-track'!C4&"/USD", "price_history", "2d")
this is usually solved by constructing an array of formulae where you stack them up in the line like:
={CRYPTOFINANCE("KRAKEN:"&'crypto-track'!C4&"/USD", "price_history", "2d");
CRYPTOFINANCE("KRAKEN:"&'crypto-track'!C5&"/USD", "price_history", "2d");
CRYPTOFINANCE("KRAKEN:"&'crypto-track'!C6&"/USD", "price_history", "2d")}
this way the 2nd fx will pick up right after 1 fx ends
you can ease your pain of a "hand job" from constructing such an array - especially if that array needs to span over the larger range - by building a formula to generate a formula. for example: https://stackoverflow.com/a/68278101/5632629
also, make sure you obey the law of array constructs and successfully avoid all array errors - https://stackoverflow.com/a/58042211/5632629

How would I reference cells in order while moving down several cells in a formula on a separate sheet?

I have been at this for hours and it's kicking me. I'm trying to build a log for someone, and I have a sheet with standard data in table format. I need the next sheet to look a certain way so that it can be exported to PDF and continue looking like the log always has - which means that it will not be a standard table.
In the Log sheet, data is all on one row, in the PrintSheet the cell references will be placed in three rows, with a gap fourth row. Obviously, when you paste formulas in Excel, it picks the row you're in, vs the next row down in the referenced sheet. I've included the formulas that "work" in blue in the image for reference, but that would involve manually subtracting 3 (or 4 depending on which one I'm doing) to each formula (Formula for reference -- =Log!$A$1&": "&INDIRECT("'log'!A"&ROW()-3).
Is there a way to dynamically write this formula so it can just be copy/pasted every 4th row when they need more in the PrintSheet? Is it possible I need to be using an array formula (that is an area of Excel that I am deeply lacking in)?
Input Sheet (log) vs Output Sheet (PrintSheet) with formulas in blue
Use a bit of maths on the row number and pull the formula down as required:
=CHOOSE(MOD(ROW()-2,4)+1,Log!$A$1&":"&INDEX(Log!A:A,QUOTIENT(ROW()-2,4)+2),Log!$D$1&":"&INDEX(Log!D:D,QUOTIENT(ROW()-2,4)+2),"","")
Log:
PrintSheet:
If you have Excel 365, you can do it using the same method but as a spill formula:
=LET(logRows,COUNTA(Log!A:A)-1,
seq,SEQUENCE(logRows*4,1,0),
CHOOSE(MOD(seq,4)+1,Log!$A$1&":"&INDEX(Log!A:A,QUOTIENT(seq,4)+2),
Log!$D$1&":"&INDEX(Log!D:D,QUOTIENT(seq,4)+2),"",""))
In this case it counts the number of rows in the log so will expand as you add more rows.
The date and time can be done in a similar way.
Instead of row()-3 etc. have a look here whether this offset calculation helps:
Column A is the row in the output list and column B is the target row from the input list

Google Sheets - new starting point for an array

In Google Sheets, running an array to transpose raw data into a readable format. The array forumula runs off of a row of data and am using the array to transpose the data into multiple rows. The issue is that for every additional row of raw data, I create five new rows of transposed data so the array formula breaks. Trying to make the array formula flex to added rows of data - any thought would be appreciated!
https://docs.google.com/spreadsheets/d/16GOsH-EUDm2IeRgUgEQ8LBEltQASfJ8hR6GXh-pqNcM/edit?usp=sharing
Rather than use an array formula, you can use an indirect formula and modulo arithmetic and integer division to do this. In k2 put the formula =indirect("A"&(3+FLOOR((row()-2)/5))) which will get the date from column A row 3 until you get down to row 7, when it starts taking from row 4. This formula can be dragged down and will jump rows every 5 as desired.
Similarly for L2 place in =indirect("B"&(3+FLOOR((row()-2)/5))) which can also be dragged down (copied) the column.
For column m we need to cycle through c2,d2,e2,f2, and g2, so we need modulo (clock) arithmentic. So in m2 place the formula =indirect(char(CODE("C")+(mod(ROW()-2,5)))&"2"). Finally for quantity we need to do both the column cycling and the incrementing rows every 5, so the formula for n2 is =indirect(char(CODE("C")+(mod(ROW()-2,5)))&(3+FLOOR((row()-2)/5))). That too can get copied on down. That should do it. There could definitely be more elegant ways.
I think not more elegant, but preserving the array formula would be =3+floor((row()-2)/5) in j2 and drag on down, and then adapt the array formula to: ={INDIRECT("A" & J2),INDIRECT("B"&J2),$C$2,INDIRECT("C"&J2);INDIRECT("A" & J2),INDIRECT("B"&J2),$D$2,INDIRECT("D"&J2);INDIRECT("A" & J2),INDIRECT("B"&J2),$E$2,INDIRECT("E"&J2);INDIRECT("A" & J2),INDIRECT("B"&J2),$F$2,INDIRECT("F"&J2);INDIRECT("A" & J2),INDIRECT("B"&J2),$G$2,INDIRECT("G"&J2)} which can be copied to 5 rows below it where the J2's become J7's and you are processing the next desired row.

Excel array Formula that copies only cells containing a string

I would prefer to use an excel array formula (but if it can only be done in VBA, so be it) that copies ALL cells from a column array that contains specific text. The picture below shows what I am after and what I have tried. I'm getting close (thanks to similar, but different questions) but can't quite get to where I want. At the moment, I am getting only the first cell instead of all the cells. In my actual application, I am searching through about 20,000 cells and will have a few hundred search terms. I expect most search terms to give me about 8 - 12 cells with that value.
formula I am using:
=INDEX($A$4:$A$10,MATCH(FALSE,ISERROR(SEARCH($C$1,$A$4:$A$10)),0))
Spredsheet Image
To make this work efficiently, I recommend having a separate cell holding the results count (I used cell C2) which has this formula:
=COUNTIF(A:A,"*"&C1&"*")
Then in cell C4 and copied down use this array formula (The -3 is just because the header row is row 3. If the header row was row 1, it would be -1):
=IF(ROW(A1)>$C$2,"",INDEX($A$4:$A$21000,SMALL(IF(ISNUMBER(SEARCH($C$1,$A$4:$A$21000)),ROW($A$4:$A$21000)-3),ROW(C1))))
I tested this with 21000 rows of data in column A with an average of 30 results per search string and the formula is copied down for 60 cells in column C. With that much data, this takes about 1-2 seconds to finish recalculating. Recalculation time can vary widely depending on other factors in your workbook (additional formulas, nested dependencies, use of volatile functions, etc) as well as your hardware.
Alternately, you could just use the built-in Filter functionality, but I hope this helps.
You need to get the ROWS. Put this in C4 and copy down.
=IFERROR(AGGREGATE(15,6, IF(SEARCH($C$1, $A$4:$A$10)>0, ROW($A$4:$A$10)), ROW($C4)-ROW($A$4)+1), "")
Array formula so use ctrl-shift-Enter

speed up array formula

I have the following formula which I will explain below:
{=SUM(IF(($G$1:$L$1=$O$1)*($G$2:$L$2=$O$2)*($G$3:$L$3=$O$3)*($G$4:$L$4=$O$4)*($G$5:$L$5=$O$5)*($G$6:$L$6=$O$6)*($G$7:$L$7=$O$7);G21:L21))}
Here is what the worksheet looks like:
Under columns G - L we have a 'database' of all data. These columns will be added cumulatively each quarter (approx 30 columns a quarter). So after a few years we have ended up with a bunch of database columns (1000 + columns of raw data). For the sake of this demo, I have only included those 6 columns.
As you can see, each column contains specific parameters, between rows 1 - 7, which allows to identify specific CountryCode + Project Code + Category + Fiscal Year, + ... (etc.). This allows us to track down a unique specific project and retrieve its data.
What we have afterwards on the column O is a specific project we are trying to retrieve values for (you can see that the rows 1 - 7 are the same as under column G (we are trying to retrieve values for this particular project).
Here comes our formula. I have attached above. Here is what it looks like when I press F2. As you can see the IF statement is first simply checking whether the particular columns match the pre-defined criteria under column O and it sums all the columns that match all the criteria between rows 1-7.
Now here is the problem. We have a worksheet, which contains 20 projects (such as column O) and we are using this array formula there to retrieve values. The problem is that retrieving data using this way takes A LOT OF TIME. We have also adopted a principle via VBA that we iterate through all the cells, then we insert a formula, calculate array cell, and then we copy & Paste resulting value inside (so that we won't end up with full sheet of array formulas). However it still takes LONG to calculate (1 minute or so).
I was wondering, if there is a better solution how to retrieve the data in the already mentioned format (that means we have a specific criteria we are trying to find)? Maybe SUMIFS could be better? Or sumproduct? Or even compeltely different solution?
I am open to any proposal which would fasten the process.
i met similar problem about 2 weeks ago. At first i use a helper column/row. The helper column is to concatenate the 7 string in each column. then only use the IF function to check if the joined text match. Such as, assuming the helper row is row 8 per your sample, cell G8 formula would be
=CONCATENATE(G1,"|",G2,"|",G3,"|",G4,"|",G5,"|",G6,"|",G7)
and do the same for the rest including column O
=CONCATENATE(O1,"|",O2,"|",O3,"|",O4,"|",O5,"|",O6,"|",O7)
Then do a HLOOKUP
=HLOOKUP(O8,G8:L21,14,0)
In my case, the calculation time reduce from 10 min to a few seconds!
Alternatively I also found a way to do without helper column, using array again, but the idea is pretty much the same,
the formula in O21 as per your sample would be
=SUM(IF(CONCATENATE(G1:L1,G2:L2,G3:L3,G4:L4,G5:L5,G6:L6,G7:L7)=CONCATENATE(O1,O2,O3,O4,O5,O6,O7),G21:L21))
(i didn't add in the "|" delimiter for this formula, but it is better to do so)
But in the end I prefer the helper column method.
For your reference
HTH
To improve performance avoid reapeating same calculations multiple times.
This allows us to track down a unique specific project and retrieve its data.
If a combination of 7 values is unique, calculate the position of chosen project only once in helper cell (for example O15) with array formula (confirmed with Ctrl+Shift+Enter:
=MATCH(1;(G1:L1=O1)*(G2:L2=O2)*(G3:L3=O3)*(G4:L4=O4)*(G5:L5=O5)*(G6:L6=O6)*(G7:L7=O7);0)
Use the following formula in O21 and drag down:
=INDEX(G21:L21;1;$O$15)

Resources