Transpose array in countifs formula - error - arrays

The picture gives a schematic representation of the data. Columns up to 17th in the actual spreadsheet is the raw data entries.
First I sort Brand according to SUMIF and add the Brand Month Sorted into an array - ArrayCurrentMonth.
Then I add individual categories into Specialty Array.
Now what I want is to countifs number of entries with COUNTIFS formula for columns that are schematically pictured 9-12 using ArrayCurrentMonth and Specialty as Range arguments in SUM(COUNTIFS(.. function
Thus 10-12 - ArrayCurrentMonth transposed ;
Column 9 - Specialty Values
Rammaged through earlier Q&A's and found useful variants, that seems to work for others, but for me on Transpose I stubbornly get Sub or Function Not defined no matter how i use it - with Range or with Array.
ActiveSheet.Range(X;Y) = Application.WorksheetFunction.Sum(Application.WorksheetFunction.CountIfs(Range("C:C"), RTrim(Month(Mesyaz1)), Range("H:H"), "Headephones", Transpose(Range("F:F"), ArrayCurrentMonth(c)), Range("L:L"), Specialty(g)))
or
ActiveSheet.Range(X;Y) = Application.WorksheetFunction.Sum(Application.WorksheetFunction.CountIfs(Range("C:C"), "Month1", Range("H:H"), "Product1", Transpose(ArrayCurrentMonth), Range("L:L"), Specialty(g)))
or any other way I could think of just to check how it would work.
I would try looping For g=1 etc but I guess I need some Transpose anyhow
Would be grateful for some tips.

Related

Can I make an array out of a range of countif functions?

A truncated version of my data is in the form shown in the screenshot below: three columns of 5 unique names. The names appear in any order and in any position but never repeat in a single row.
My goal is to create an array that contains the number of times Adam appears in each row. I can fill down the formula=countif(A2:C2,$I$2) in a new column, or if I write the array manually for each row, it looks like:
={countif(A2:C2,$I$2);countif(A3:C3,$I$2);countif(A4:C4,$I$2);countif(A5:C5,$I$2);countif(A6:C6,$I$2)}
Where cell I2 contains "Adam". Of course, this is not feasible for large data sets.
I know that arrays are effectively cells turned into ranges, but my main issue is that the cell I'm trying to transform already references a range, and I don't know how to tell the software to apply the countif down each row (i.e. I intuitively would like to do something like countif((A2:C2):(A99:C99),"Adam") but understand that's not how spreadsheets work).
My goal is ultimately to perform some operations on the corresponding array but I think I'm comfortable enough with that once I can get the array formula I'm looking for.
try:
=ARRAYFORMULA(IF(A2:A="",,MMULT(IF(A2:C="Adam", 1, 0), {1;1;1})))

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)

Array Formula Index Match to Select Cell Based on Second, Third, and Fourth Minimum Value

I have a cell that currently uses an array formula to return the name associated with the minimum hours worked for all my employees. However, what I am trying to do now is write an array formula that lists the three next employees with lowest hours. I have written a formula similar to this in the past, but can't seem to get the two formulas to appropriately match up.
My current return minimum employee formula in G5:
={INDEX(A:A,MATCH(MIN(IF(B:B=G3,IF(C:C>=$G$2,D:D)))&G3,D:D&B:B,0))}
Here is an example of my data:
...and now I'm attempting to incorporate in into the following array formula that would return a list of qualifying results as I dragged it down a column:
={(IF(ROWS(G$7:G7)<=F$8,INDEX($A$2:$A$8,SMALL(IF(Employees!$B$2:$B$8=$G$3,ROW($A$2:$A$8)-ROW($A$2)+1),ROWS(G$7:G7))),""))}
Currently, this array formula is only set up to match on position title and not the other qualifiers that I need from my minimum employee formula. How can I mesh the two formulas correctly? Thank you for any and all help and please, let me know if you need any clarification.
The ideal array result would show Boris and two blanks in consecutive rows in the Next 3 Employees chart.
Set your page up like this:
With the ranking in column F.
Then it is a quick modification of the last formula. Instead of MIN we use Small. The k part of the small equation is the ranking number:
=INDEX(A:A,MATCH(SMALL(IF(B:B=$G$3,IF(C:C>=$G$2,D:D)),F5)&$G$3,D:D&B:B,0))
This goes in G5. Is confirmed with ctrl-shift-enter. Then copied down for rows.
If do not want the errors to show then wrap it in IFERROR:
=IFERROR(INDEX(A:A,MATCH(SMALL(IF(B:B=$G$3,IF(C:C>=$G$2,D:D)),F5)&$G$3,D:D&B:B,0)),"NO MATCHES")

Need Excel Forumla To Sort 2 Columns Which Both Contain Array Formulas

I have created an excel spreadsheet to keep track of the >400 different types of beer that I have tried along with their home brewery, alcohol content, & rating. I have used array formulas to calculate how many different breweries and how many beers from each brewery as well as how many different styles and how many of each style I have tried. The problem I am running into is sorting the data. I have a list of all the various breweries (excluding duplicates) in column K. In column L I have the # of different beers I have tried from each brewery. I would like to sort columns K & L from most largest to smallest using the values in column L. Same thing applies for columns M & N except it's the styles not the breweries I'm tracking. I can't figure out how to do it since I'm using two array formulas, one in each column, and basically the results are conditioned on the results of the other. Any help on this matter would be greatly appreciated. Below is a link so you can download the spreadsheet to better understand what I'm doing.
https://www.dropbox.com/s/cysa2rvcgcbs13c/TGS.xlsx?dl=0
Also the array formulas I'm using to make the unique lists in columns K and M are my first try at array formulas. Therefore, if someone could tell me if they are efficient or not and if there's a better way to do what I'm trying to do which is look through the data in column B, discard the duplicates, and extract the unique breweries into column K. Same thing applies the styles in columns C & M.
Thanks in advance!
While it is marginally possible to perform all counting and ranking within a single formula, the use of Helper columns makes much more sense and reduces calculation load substantially. For all intents and purposes, your existing unique lists and COUNTIFS are what the helper columns would contain and then you can return the values to another column based on the ranking of the COUNTIF returns.
      
I modified your array formula from K2 and put it into P2 as,
=IF(LEN(P1), IFERROR(INDEX($B$2:$B$501, MATCH(0, IF(LEN($B$2:$B$501), COUNTIF(P$1:P1, $B$2:$B$501&""), 1), 0)), ""), "")
The standard formula in Q2 was similar to the one previously in L2 as,
=IF(LEN(P2),COUNTIF($B$2:$B$501,P2), "")
The formula in L2 could now return a ranked result from column Q with this standard formula,
=IFERROR(LARGE($Q$2:$Q$501, ROW(1:1)), "")
With the ranked return in L2, K2 could return a matching brewery from column P with this array formula,
=IF(LEN(L2),INDEX($P$2:$P$501,SMALL(IF($Q$2:$Q$501=L2,ROW($1:$500)), COUNTIF(L$2:L2, L2))),"")
Columns S, T, M and N were similarly modified. Then everything was filled down to row 501.
I've made the modified workbook available on my SkyDrive here for you to reference and download. Let me know if you want it removed.
TGS (Jeeped).xlsx
More information on this method from Multiple Ranked Returns from INDEX(…) with Duplicate Values

Excel arrays count totals using criterias from multiple ranges (or sheets)

What I would like to do is to count the amount of lines that matches criterias to be verified in two arrays.
I can't use VBA, add new columns (for instance a new column with VLOOKUP formula) and preferably use arrays.
I have two separate ranges, each with a ID column for the identifier and other fields with data.
For instance, range 1:
Range 2:
If I had only to check the first range I would do:
={SUM((D4:D7="Red") * (E4:E7="Big"))}
But I don't know how to check also using data from the other range.
How, for example, to count the number of items that are Red, Big and Round by using both Ranges ?
Put this in the cell F4:
=IF((VLOOKUP(C4,$C$11:$D$12,2)="Round")*(D4="Red")*(E4="Big"),1,"")
Note that the behavior of VLOOKUP is that it finds the value up to the first parameter. Since there's no 1 in your second dataset, this first cell is going to show "#N/A", which I don't know how to solve, but when you extend this formula down to also compare the other sample data in the first set, the ID numbers 2 and 4 will show up as "yes" for you.
Edit: You wanted a count of this list. So after this, it should be easy to get a count of cells in this column using the COUNT function.
Try this array formula
=SUM((D4:D7="Red")*(E4:E7="Big")*ISNUMBER(MATCH(C4:C7,IF(D12:D13="Round",C12:C13),0)))
The last part is the added criterion you want - the IF function returns {2,4} [IDs where Data 3 is "Round"] and then you can use MATCH to compare C4:C7 against that. If there is a match you get a NUMBER (instead of #N/A) so you can then use ISNUMBER to get TRUE/FALSE and that feeds in to your original formula - result should be 2

Resources