I have a table with 2 columns, where
A contains objects, and
B their costs
I am trying to display the object that corresponds to the minimum cost of a range of non-adjacent cells. I wrote this formula:
=INDIRECT(CELL("address",INDEX(CHOOSE({1,2,3,4,5,6,7},A3,A9,A12,A13,A18,A21,A22),MATCH(MIN(B3,B9,B12,B13,B18,B21,B22),CHOOSE({1,2,3,4,5,6,7},B3,B9,B12,B13,B18,B21,B22),0))))
I get #VALUE!, what's the error in my approach?
Try just the INDEX/MATCH part
=INDEX(CHOOSE({1,2,3,4,5,6,7},A3,A9,A12,A13,A18,A21,A22),MATCH(MIN(B3,B9,B12,B13,B18,B21,B22),CHOOSE({1,2,3,4,5,6,7},B3,B9,B12,B13,B18,B21,B22),0))
I am assuming that you just want to get the name of the object whose value is the minimum among the cells you detailed.
=INDEX(A:B,MATCH(MIN(B3,B9,B12,B13,B18,B21,B22),B:B),1)
Screenshot:
Let us know if this helps.
Related
I have a countifs formula that seems to be letting me down.
It's using 2 different criteria and both are dynamic arrays - here represented by the cell ref and the hashtag:
COUNTIFS(A:A,B1#,C:C,D1#)
The dynamic arrays in cells B1 and D1 are working fine, and if I change the countifs so only 1 of the criteria refers to a dynamic range (removing the hashtag and selecting 1 of the results in the array) then it works fine. The problem is when I need it to use 2 (or more?) dynamic ranges.
Any thoughts?
if the items are independent of each other as in B1 does not directly correlate to D1 and B2 directly correlates to D2 then you need to Transpose one of the arrays.
=COUNTIFS(A:A,B1#,C:C,TRANSPOSE(D1#))
Note:
This will create a 2D array with as many rows as in B1# and as many Columns as in D1#. So to get the total wrap it in SUM or SUMPRODUCT.
Also, The max independent arrays are two.
Also that it is an AND situation so the value in A must be equal to the a value in B and the value in C in the same row, must be equal to a value in D
If one wants more than two we need to move away from countifs and use array type formula which will require the use of ranges that encompass the most rows that would be used and not full columns.
=SUMPRODUCT(ISNUMBER(MATCH(A1:A100,B1#,0))*ISNUMBER(MATCH(C1:C100,D1#,0)))
This version is AND like the COUNTIFS where the values in A and C on the same row must exist their corresponding lists to be counted. IF you want to count them individually then change the * to + which makes it an OR.
And the use of ISNUMBER(MATCH(A1:A100,B1#,0)) can be added as many as desired changing the ranges as necessary.
Edit: This will not work, see below comment by #Scott Craner
I'm unsure if COUNTIFS work well with dynamic arrays, which is what you are currently using.
A workaround can be to try use SUMPRODUCT
=SUMPRODUCT((A:A=B1#)*(C:C=D1#))
I'm trying to count the number of distinct text from a specific date in a data table.
Data Sample with expect result :
I was able to figure out how to count the distinct element from a range I specify, because I can determine the first and last row containing the date.
=SUMPRODUCT(1/COUNTIF(B2:B15,B2:B15))
I have tried to modify my formula so that it determines the cell range by itself but without success.
I searched for an answer, using a combination of CELL and MAXIFS, example below, but Excel does not accept the formula.
=CELL("row",MAXIFS(A2:A15,A2:a15,D2))
I've looked at the INDEX formula, but I can't figure out how to do what I want to do. 😑
Any idea what I'm doing wrong, or what I should be doing instead?
Thanks, I appreciate it!
If you have Office 365 and the new Dynamic Arrays, this sort of formula has become ridiculously easy.
This formula in cell E3:
=COUNTA(UNIQUE(FILTER($B$2:$B$15,$A$2:$A$15=D3)))
Copy down.
You can also generate the unique list of dates with this formula in D3, which spills down automatically and does not need to be copied.
=UNIQUE(A2:A15)
It wasn't easy, but by separating each step of the problem, I was able to solve it.
Note that my solution only works because my dates are sorted.
Here's the final formula in the cell "One formula to rule them all":
=SUMPRODUCT(1/COUNTIF(INDIRECT(CONCATENATE(ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2),":",ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2))),INDIRECT(CONCATENATE(ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2),":",ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2)))))
Here are my explanations of my process:
Formula if I select the range :
=SUMPRODUCT(1/COUNTIF(B2:B15,B2:B15))
Formula to get the first iteration
=ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2)
Formula to get the last iteration
{=ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2)}
Create range from two addresses
=INDIRECT(CONCATENATE(F3,":",G3))
Formula giving me the expect result
=SUMPRODUCT(1/COUNTIF(INDIRECT(CONCATENATE(F3,":",G3)),INDIRECT(CONCATENATE(F3,":",G3))))
Please see the screenshot of my schedule below.
I need a formula that will populate the END_DATE column with the date corresponding to the very last (rightmost) 'x' for each row..
Is there a way to read the rightmost 'x' in a row, and populate a cell with the date above that 'x'?
Any help is much appreciated.
Thanks,
PJ
Updated based on #Dan's very correct feedback
You can use Array/CSE formula:
=INDEX($E$4:$K$4, 1, MAX(IF(E5:K5="X",COLUMN(E5:K5)-(COLUMN(E5)-1))))
Using Ctrl+Shift+Enter to enter that in. This will find the max column number that contains an X and subtract 3 from it (assuming the range we are searching is D2:J2, otherwise the -3 will have to be adjusted to compensate. Then using Index() to find the corresponding value for that column.
as an alternative to an array or CSE formula you can use aggregate which performs array like operations within the aggregate function. Adjust the references to suit your needs, but avoid using full row/column references within aggregate due to the array like calculations it performs.
This solution uses a combination of INDEX and AGGREGATE
=INDEX($4:$4,AGGREGATE(14,6,COLUMN($E5:$K5)/($E5:$K5="x"),1))
I used the above formula in the yellow cells shown in the example below.
I'm trying to find the most common value in a range given a previuous value occurs, so for instance, if Shared mailbox (Col C) is equal to Finance tell me the most common team number (Col B) of the users who access it:
The function I have so far is (obviously ignore the absolute cell references)
=INDEX($B$2:$B$20,MODE(MATCH($C$2:$C$20,$C$2:$C$20,0)))
I could do this with a pivot but I need to insert the value into a cell and vlookup in a pivot wont cut it. Also there are tens of thousands of rows. But essentially the pivot result is what I'm looking to get to, just in a cell via a formula.
Here is an example of the table, a pivot and a peek at the formula and results.
Excel image with pivot
Any and all help is welcome.
Cheers
Matt
You can use an array formulas. Use the mode function over an if
{=MODE(IF($C$3:$C$18=F4,$B$3:$B$18))}
Refer to image for example:
You might be looking for this formula:
=MODE.SNGL(IF(C1:C999="Finance",B1:B999))
CtrlShiftEnter
p.s. you can replace the hard-coded "Finance" with any cell reference.
EDIT
Indeed if there's only one matched row, or two rows with different values, the MODE will fail because there is actually no single mode. You want then to return the "first" match, therefore wrap the formula inside IFERROR with an INDEX/MATCH alternative:
=IFERROR(MODE.SNGL(IF(C1:C999="Finance",B1:B999)),INDEX(B:B,MATCH("Finance",C:C,0)))
CtrlShiftEnter
Excel Example Image
Hi there! My problem is a little hard to describe so I hope the title isn't misleading.
As you can see in the image, there is a column of different 2-letter-strings with associated values in another column next to them. On the right there is another table with all the strings and a column next to it where I want Excel to sum all the values that are associated with that particular string.
So Excel has to basically scan trough the string column on the very left and check for "GE" for example. If it is successful in finding it, it has to refer to the cell in the same row that references the value and then add this value into the cell where it sums all the "GE" values.
I tried some different things already but I wasn't able to find a solution. I hope you can help me! :)
You'll have to use the SUMIF function. Enter it in every cell of column G where you want to see the result. As an example, G3 cell should be:=SUMIF(B3:B12,"GE", D3:D12)EDIT: You could also pick the value from F column to avoid typos in the function, so you can also do it like:=SUMIF(B3:B12,F3, D3:D12)