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
Related
I am using Office 365 currently and I want to make a visualization tools using MAKEARRAY functions.
For example, if I want to display sequential of 32 items, I would display it in this way:
I use the following formula of Makearray to generate the custom array for me
Note: Formula is pasted at cell value F3 .
=MAKEARRAY(ROUNDUP(B2/B3,0),IF(E3#=ROUNDUP(B2/B3,0),MOD(B2,B3),B3),LAMBDA(row,col,"O"))
but it seems like after debugging, this part of the formula are giving it the problem are these
IF(E3#=ROUNDUP(B2/B3,0),MOD(B2,B3),B3)
as I debugging the formula separately as shown in picture below, it can generate the correct amount of columns as it is supposed to.
Note: Generate exactly same amount to the no of columns if row number is not matching;
Generate modulus remainder formula if row number is matching to roundup of no. of items divided by no. of columns.
But in the end, I put that problematic formula back into the MAKEARRAY function just give only a single columns, which seems like it is quite wrong.
May I know why it display single columns even though by right, it should display the correct amount of no. of columns?
What about:
Formula in C1:
=WRAPROWS(INDEX("O",SEQUENCE(A1,,,0)),A2,"")
Or rather:
=WRAPROWS(EXPAND("O",A1,,"O"),A2,"")
MAKEARRAY does not expect an array in the number of columns. It is a set number. It will iterate the number of rows and number of columns to create the array. It will always be square and not jagged.
So you need to do the math to change the value:
=MAKEARRAY(ROUNDUP(B2/B3,0),B3,LAMBDA(rw,clm,IF(10*(rw-1)+clm>B2,"","O")))
Now as soon as the space is greater than the 32 it puts in "" instead of "O"
If I have a range in excel, say A2:I2, that is used to store the results from a monthly competition, what formula do I use in excel to return the average of the three most right values?
The formula needs to account for not all columns being filled, i.e. one player might have 5 results, one might have 9, and one might have 1.
Thanks
You can combinedly use TEXTJOIN() and FILTERXML() like below.
=AVERAGE(FILTERXML("<t><s>"&TEXTJOIN("</s><s>",TRUE,B2:J2)&"</s></t>","//s[position()>" & COUNTA(B2:J2)-3 &"]"))
Here "<t><s>"&TEXTJOIN("</s><s>",TRUE,B2:J2)&"</s></t>" will construct a valid XML string.
XPATH parameter "//s[position()>" & COUNTA(B2:J2)-3 &"]" will return last 3 nodes to calculate Average by AVERAGE() function.
COUNTA(B2:J2)-3 will detect how many nodes have before last 3 nodes so that we can return rest of nodes means always last 3 nodes by FILTERXML() formula.
More about FILTERXML() here by JvdV Extract substring(s) from string using FILTERXML
Edit: For google sheet you can use below formula.
=AVERAGE(FILTER(B2:J2,(COLUMN(B2:J2)-Column(A2))>IF(COUNTA(B2:J2)<=3,0,COUNTA(B2:J2)-3)))
If one has Microsoft365, you could also use:
Formula in K2:
=AVERAGE(INDEX(SORTBY(FILTER(B2:J2,B2:J2<>""),SEQUENCE(1,COUNT(B2:J2)),-1),SEQUENCE(MIN(3,COUNT(B2:J2)))))
I am trying to create a spreadsheet that will be used to provide quotes to customers. Some part-numbers apply to a single item. Some part-numbers are bundles of up to 4 items. I am trying to create a formula that returns all of the values associated with a given part-number.
Initially, I had two section in the quote - one that uses VLOOKUP to return part-numbers with single items and one that uses an array formula that returns an array of items.
The first formula is
=IF(ISNA(VLOOKUP(B12,PriceList,2,FALSE)),"",VLOOKUP(B12,PriceList,2,FALSE))
The second is
{=IFERROR(INDEX(Bundles!$B$2:$B$101, SMALL(IF($B$33=Bundles!$A$2:$A$101, ROW(Bundles!$B$2:$B$101 ) - 1,""), ROW() - 32 )),"")}
Screenshot showing results of first two formulas
Both work fine on their own. They rely on two data tables "PriceList" and "Bundles"
I want the sales reps to be able to type a part-number in column B and get the correct part descriptions - whether it is 1, 2, 3, or 4 items - to display in column C. I want them to be able to enter multiple part numbers on the same quote.
I tried to base this on the part number
=IF(LEFT(B29,4)="BUND",IFERROR(INDEX(Bundles!$B$2:$B$101,SMALL(IF($B$29=Bundles!$A$2:$A$101,ROW(Bundles!$B$2:$B$101)-1,""),ROW()-28)),""),VLOOKUP(B29,PriceList,2,FALSE))}
This works for bundled items, but repeats single items.
I would like to have a single data source (PriceList) and a single formula.
Partnumbers in Datasource
What I am now trying to do is use COUNTIF. For example if COUNTIF returns more than 1, use the array formula, else use the VLOOKUP formula.
I picture it to be something like
IF((COUNTIF(PriceList,Quote!B11)>1),"BUNDLE",IF(ISNA(VLOOKUP(Quote!B11,PriceList,2,FALSE)),"",VLOOKUP(Quote!B11,PriceList,2,FALSE)))
where "BUNDLE" is replaced by an array function. I can't seem to come up with the right array formula.
I tried
{=IF((COUNTIF(PriceList,Quote!B11)>1),IFERROR(INDEX(Bundles!$B$2:$B$101, SMALL(IF($B$11=Bundles!$A$2:$A$101, ROW(Bundles!$B$2:$B$101 ) - 1,""), ROW() - 32 )),""),IF(ISNA(VLOOKUP(Quote!B11,PriceList,2,FALSE)),"",VLOOKUP(Quote!B11,PriceList,2,FALSE)))}
This returns four rows of the same item for single items and nothing for bundles
I had thought about placing the array function in another cell and referencing that cell, but this does not help if the bundle contains more than one item.
Any thoughts or advice would be welcome.
I am currently trying to use some excel formulas like "Index"/"Max"/"If" with multiple criteria. This means I want to lookup all values in A2:I2 and search them in my second table in A8:A20. At the same time I want to lookup the maximum in C8:C20 and for the entry that
1) matches A2:A20 and 2) has the highest value in C2:C20 I want to get the value of the "Result" column be displayed in I7, which is "D".
After trying multiple variations with Index/Vlookup/Max/If etc. I cannot find any formula for this problem to handle multiple matching criteria within arrays.
Perhaps is there any VBA solution to loop through both tables and get the result displayed below?
P.S. As this is only a small part of my worksheet it is not efficient to use one Index formula for each cell trying to match my second table. It would be great to work with two arrays matching each others values.
Using your provided sample, in result cell I7 use this formula: =MAX(INDEX((A8:A20=A2:I2)*C8:C20,))
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")