Excel: contingent upon column, increment a different column and multiply all sums - arrays

So I have column A with mpnths. Column B has percent win and loss. I want to add 1 to the value in column B and then find the product of all values in column B to determine the compound growth of the dataset. Then I want to take this value and put in in my reports sheet.
=PRODUCT(SUM(1,IF(MONTH('#MOMO Trades'!A1:A1000)=4,'#MOMO Trades'!B:B,0)))
Please help me correct this formula.
thanks!

In order for the SUM function to add 1 to each row individually, you will need to use an array formula, rather than a formula. Otherwise, it will try to add 1 to an array, which it can't do.
To do this, enter the formula as you would normally, but when you have typed it press Ctrl+Shift+Enter instead of just Enter. It will show up surrounded by braces, like this:
{=PRODUCT(SUM(1,IF(MONTH('#MOMO Trades'!A1:A1000)=4,'#MOMO Trades'!B:B,0)))}

Related

Can Excel Index-Match or something like it match 1 row but return another?

I have a chart that shows the salaries for various medical specialties by percentile (each row is a specialty and each column is a percentile).
I want to be able to take a separate chart of physicians and their salaries, and automatically fill in what percentile each of their pay is.
https://i.imgur.com/NCtHHAB.jpg
If the physicians were all in one specialty, then I could just use Index-Match like so:
=INDEX('[Percentiles Chart]'!$B$3:$F$4, 1, MATCH(K3,'[Percentile File]'!$B$4:$F$4,1))
This formula works because it's choosing the column based on just the salaries in that one row, and always returning the top row. If I wanted it to choose between different rows, how could I do that without writing an "If" formula for every single row?
In other words, I want excel to look down column A in the example picture to pick the right specialty, then compare the salaries across the row and return what's in row 2.
Thank you!
As you rightly mentioned, there is no easy way to accomplish what you are looking for since the combination of Index/Offset/Match functions will return the data from the row that is matched and not some other row. Here is a formula that I have tried and it works exactly like you want. It is slightly hacky and uses SUMPRODUCT but gets the job done.
In your spreadsheet, if you enter the below formula, you would see that it gets the correct percentile value.
=OFFSET($B$2,0,SUMPRODUCT(($A$3:$A$6=J3)*($B$3:$F$6<K3)),1,1)
Here is how it works. The first part Sumproduct basically matches the name of specialty in range A3 to A6 and returns true for a match. The second part in sumproduct checks how many values in the range B3 to F6 are less than the given value (for example K3). When these two results are multiplied, it gives the number of values less than given value in the row of matching specialty which is equivalent to the offset of the column in the range. So, the OFFSET function simply navigates to that column and returns the value of the percentile. The below screenshot should help you understand it better.
If my explanation confused you :), you may want to play around with this formula to see how exactly it works.
Note the last column that says 100 in the percentiles table. That is simply to show correct value in case salary is greater than 90 percentile value.

Excel - Perform Summation of Column of If Statements In One Cell

I feel like I've done this before but am at a total loss after looking at a lot of pages already.
Consider a set of data given in two columns, x and y. X column is always ascending in value, y is random. I need a single cell to calculate the sum of a column of IF statements within a specified range of x without actually displaying the column of IF statements or using VBA. In other words: I want to turn this (IMG1) into this (IMG2)
In the first picture, the z column has this formula for each cell in a descending order: =IF(AND(B2>0,A2>$D$2,A2<$D$3),A2-A1,0)
I feel like I can use SUMIFS or an array formula somehow but I'm at a loss.
Please forgive if I improperly posted this somehow - this is my first post.
-Adam
Try this Array Formula which requires a special key stroke Ctrl+Shift+Enter instead of Enter alone.
=SUM(IFERROR((A2:A11>0)*(B2:B11>0)*(A2:A11>D2)*(A2:A11<D3)*(A2:A11-A1:A10),0))
Confirm this formula with Ctrl+Shift+Enter

Index/Match with IF Statement

As you can see, I have a database table on the left. And I want to add in IF statement that allows me to lookup the [Code], [Name] and [Amount] of the top 5 of Company A ONLY. Then do a top 5 for Company B and so on. I have managed to lookup the top 5 out of ALL companies but cannot seem to add a criteria to target specific company.
Here are my formulas so far:
Formula in Column K [Company]: = INDEX(Database,MATCH(N3,sales,0),1)
Formula in Column L [Code]: = INDEX(Database,MATCH(N3,sales,0),2)
Formula in Column M [Name]: = INDEX(Database,MATCH(N3,sales,0),2)
Formula in Column N [Amount]: = LARGE(sales,ROW(1:20))
The intended result is to show the top 5 sales person in each company along with their [Code], [Name] and [Amount], feel free to suggest any edits to the worksheet.
Here's an alternative if you know the code is unique. After putting A into K3:K7
First get the highest amounts for Company A starting in N3
=AGGREGATE(14,6,Database[Amount]/(Database[Company]=K3),ROWS(N$1:N1))
Then find the code which matches the amount, but only if it hasn't been used before (this assumes that the code is unique) starting in L3
=INDEX(Database[Code],MATCH(1,INDEX((Database[Company]="A")*(Database[Amount]=N3)*ISNA(MATCH(Database[Code],L$2:L2,0)),0),0))
Then find the matching name with a normal INDEX/MATCH starting in M3
=INDEX(Database[Name],MATCH(L3,Database[Code],0))
Okay, I have achieved this with the use of a helper column which you can hide. Please nnote though that this will only work as long as there are not more than 9 identical totals for any 1 company, I don't think you should have that issue but it may occur, the digits being added by the helper column would need to be tweaked
First Helper Column:
Adds a digit to the end of the total representing the number of times that amount already exists above for that company. This formula is =CONCATENATE([#Amount],COUNTIFS($A$1:A1,A2,$D$1:D1,D2))*1
This is multiplied by 1 to keep the number format for LARGEto work with.
Second Helper Column:
This is an array formula and will need to be input by using Ctrl+Shift+Enter while still in the formula bar.
The formula for this one is:
=LARGE(IF(Company="A",Helper),ROW(1:1))
What this formula does as an array formula is produce a list of results based on the IF statement that LARGE can use. Rather than the entire column being ranked largest to smallest, we can now single out the rows that have company "A" like so:
=LARGE({20000;20001;20002;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;15000;14000;30000;FALSE;FALSE;FALSE;FALSE},ROW(1:1))
LARGE will only work with numeric values so the FALSES produced where column A does not match "A" will be ignored. Notice why I have used the helper column here to eliminate unique values but not affect the top 5.
ROW(1:1) has been used as this will automatically update when the formula is dragged down to produce the next highest result in this array.
The main formula for top 5 array
Again this is an Array formula so will need to be input by using Ctrl+Shift+Enter while still in the formula bar.
=INDEX(Database,SMALL(IF(Company="A",IF(Helper=$O3,ROW(Company))),1)-1,COLUMN(A:A))
With array formulas for some unknown reason IF(AND()) just does not work for me so I have nested two IF's instead.
Notice how I am again checking whether the first column matches "A" and then whether the last column matches the result of the second formula. What will happen is where both of these conditions match in the array (as in both produce TRUE for the same row) I wanted the row number to be returned.
IF({TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;FALSE},IF({FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;TRUE;FALSE;TRUE;FALSE;FALSE},{2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20}))
It looks like a mess I know, but the position where both TRUEs align gives us the row 16 as a result.
{FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;16;FALSE;FALSE;FALSE;FALSE}
As I know that there can only be one match possible for this, I use SMALL to grab the first smallest number to use in the INDEX formula for row and deduct 1 as we are not considering the headers in the INDEX formula so we actually want the 15th result.
Again, COLUMN(A:A) has been used for the column number to return as this will automatically update when the formula is dragged across.
If you are struggling with my explanation and want me to provide more clarity, feel free to reach out and I will try my best to explain the logic in more detail

SUMIFS function having a sum range as a product of 2 ranges, Array Formulas

I'm trying to minimize creating uneccessary tables in Excel, and instead of creating a table to multiply columns A and B, can I do it within the IF formula? Perhaps using Array formulas?
I tried Ctrl + Shift + Enter to enter the following formula:
SUMIFS($A$1:$A$10*$B$1:$B$10,$C$1:$C$10,"Value")
however it did not work.
Basically, I want to sum the product of A & B (i.e A*B) if the value in C is equal to "value".
SumProduct is what you need
=SUMPRODUCT($A$1:$A$10,$B$1:$B$10,--($C$1:$C$10="Value"))
Entered as a standard (not array) formula
This formula checks if the value in Column C is equal to 4 in this example. If so, it returns the product, if not, it returns 0. You enter this formula in for example column D and drag it down.
=IF(C1=4;SUMPRODUCT(A1:B1);0)

Excel table lookup matching values of two columns

I'd like to create a table lookup formula that matches two columns. For instance, suppose I'd like to find the value of the Letter column at the row where the Type column is Biennial and the Result column is Warning.
A B C
1 Letter Type Result
2 A Annual Exceeds
3 B Biennial Warning
4 C Biennial DevelopmentNeeded
5 D Biennial PartiallyMeets
6 E Annual Meets
What would the formula look like to accomplish this?
The SUMPRODUCT() formula is really apt for situations where you want to lookup a value with multiple criteria. It is most convenient when wanting to look up numeric values, but it can be adjusted to look up string values as well. As a bonus, you can avoid having to use array formulas.
This particular problem can be tackled with the following formula (indentation added for legibility, which you can do in Excel formulas using ALT + ENTER):
=INDEX(
$A$2:$A$6,
SUMPRODUCT(
($B$2:$B$6 = "Biennial") *
($C$2:$C$6 = "Warning") *
ROW($A$2:$A$6)
) - 1
)
First, SUMPRODUCT() is used to filter out the proper rows using ($B$2:$B$6 = "Biennial") and ($C$2:$C$6 = "Warning"); the multiplication operator * functions as an AND operator (the + operator would function as an OR operator).
Then the result is multiplied by ROW($A$2:$A$6) to find the particular row that has the combination. SUMPRODUCT() then adds everything up, which in this case gives us 3. As the result sought is actually on row 2 due to the column headings, we subtract 1. By applying the INDEX() function, we get the desired result: B.
Beware though that this is the case if and only if the combination sought is unique. If the combination sought exists more than once, this will break down.
Another method that avoids array entry is:
=INDEX($A$2:$A$6,MATCH(2,index(1/(($B$2:$B$6="Biennial")*($C$2:$C$6="Warning")),0)))
It exploits the fact that the match function ignores certain errors and that index manages arrays naturally.
You can use an array formula if you like:
=INDEX($A$2:$A$6,MATCH(1,($B$2:$B$6="Biennial")*($C$2:$C$6="Warning"),0))
Enter in with Ctrl+Shift+Enter
If you want to do this without array formulas, one way you could do it is by creating a helper column.
Column D to have the formula:
=B2&C2
Copied down
Then the new formula could be:
=INDEX($A$2:$A$6,MATCH("BiennialWarning",$D$2:$D$6,0))
It's just a play on the text, really.

Resources