I'm trying to sum cell values based on an two adjacent cell values to help me organize/visualize my investment portfolio activity. I want to sum only the values in the cells under column B if the accompanying cell in column C and D meet a certain requirement.
Basically, for the values in B2:B1000, take the values for B(n) where C(n) equals "Deposit" and D(n) is equal to "Robinhood" and sum them. Below is a screenshot indicating the cells within column B that I want summed (in red) based on the criteria that meets both conditions. The below logic should give you the sum $1100.
I tried to at least check if C(n) equals Deposit with this line but then it just sums all of the values in column B.
=SUM(IF(C2:C1000=G2, B2:B1000, 0))
My guess is some of the cells in column C meet the condition it sums all of column B. That's the first problem. The second problem is I can't introduce the second condition without creating some sort of error.
My specific case is happening on google sheets.
Answer
Use SUMIFS(): =SUMIFS(B:B,C:C,"Deposit",D:D,"Robinhood")
Related
I have a table which shows the distance between point A and multiple point B's.
Point B is listed as a series of columns (Scout groups: 104th Portsmouth, 2nd Portsmouth, etc.).
From each row, I identify the 3 closest points to Point A (by finding the 3 smallest distances).
I use INDEX to extract the column number for each (for example, the smallest) and return the group name from the column header in Row 1.
I want to use an ARRAYFORMULA because the number of rows in the table will change over time.
The problem is, it only returns a single answer and does not populate down the column as expected.
I have a similar problem with the find a minimum formula in cell R2
My latest attempt (in cell V2) is
=ARRAYFORMULA(INDEX($A$1:$P$1,,MIN(IF($A2:$P=R2,COLUMN(A:P)))))
My latest attempt (in cell R2) is
=ARRAYFORMULA(SORTN(TRANSPOSE(A2:P2),1,0,1,TRUE))
$A$1:$P$1 are the column headers - the Scout Group names (point B)
R2 is the cell containing the calculated smallest distance from the row (that I want to lookup).
$A2:$P is the range to search for the value in R2.
Screenshot
I expect the ARRAYFORMULA to populate down to the last row.
I have searched (and searched and searched) for a solution, trying many different approaches - all without success. So... it's time to ask for some help.
Example spreadsheet with data and formula
I think this gets the answers you're looking for (change end range as needed)
R2:
=byrow(A2:P25, LAMBDA(row, ARRAYFORMULA(SORTN(transpose(row),1,0,1,TRUE))))
V2:
=byrow(R2:R25, LAMBDA(row, ArrayFormula(INDEX($A$1:$P$1,,MIN(IF($A2:$P=row,COLUMN(A:P)))))))
I'm struggling with a Google Sheets arrayformula. I want to make an arrayformula to show rank position of Column B values (TOT). With my formula I just achieve a copy of the first position. I don't want duplicate values in the rank, so if there is two equal values the Column A sets the priority.
={"POS";ARRAYFORMULA(IF($B2$B:$B<>"";RANK.EQ(B3;B3:B42;0)))}
Test Document:
https://docs.google.com/spreadsheets/d/1qzs1nvpzG0VgygxbXF9bKxvGaAq-H29oI1aquupYNFc/edit?usp=sharing
If you put this in cell C2, it will rank them as you're trying to do. If you wanted to match the other direction (lowest to highest), then swith the sort parameter from false to true.
=Filter(match(B2:B+(A2:A/1000),
Sort(Filter(B2:B+A2:A/1000,B2:B<>""),1,false),0),A2:A<>"")
You also appear to have duplicates including in column A (example see rows 4,25,35). If you wanted to exclude the duplicates (effectively reducing the number of ranked values), This can be done using the unique function which would create a 17 in each row.
=Filter(match(B2:B+(A2:A/1000),
Unique(Sort(Filter(B2:B+A2:A/1000,B2:B<>""),1,false),0)),A2:A<>"")
I have a table of items with its buying and selling rates. Against each transaction, I wanted to show the item qty currently available and the current cost. Here is a screenshot of the table.
For the columns of Qty and Rate, I have used the formulas as shown below:
=SUMPRODUCT(C$2:C-F$2:F,B$2:B=B2,A$2:A<=A2)
=SUMPRODUCT(I$2:I/J2,B$2:B=B2,A$2:A<=A2)
Is it possible to convert SUMPRODUCT formulas as an array formula (returning array) so that it automatically fills whenever a row is added? Something like filling a column using FILTER or QUERY?
Regards,
Pravin Kumar.
I am making an assumption that this is your goal:
To automatically fill the quantity remaining column with the result of the difference between the two values, if and only if, there are two values provided.
A solution to this objective is:
=arrayformula(if(and(C2:C<>””, F2:F<>””), C2:C-F2:F, “”))
This produces a formula that subtracts C from F only if both C and F have values, and for all rows that have values in both C and F. If one of the rows does not have a value, the result will yield “” (blank). This formula should be posted at the top of the column where you want these results to start. In your screenshot example this would be cell J2. NOTE: 0 is still a value, and also that an array formula will not overwrite manually input data, so once you paste that function in J2, you will have to clear the cells below in order for it to auto populate.
I have a spreadsheet with several columns and I want to return a different value based on the value in Column A and if any of the other columns show a true or 1.
For example
If column A has the value "A" and any column B-N is either TRUE or 1 then I want to return "Good" to column O
If column A has the value "B" and any column B-N is either TRUE or 1 then I want to return "Best" to column O
Link to spreadsheet: https://docs.google.com/spreadsheets/d/12k9usKsOgrOUhtW5WBvfY7WB5hbfnTMSPgXtrqcRFjM/edit?usp=sharing
Try this in cell O2 (where your sample sheets only has values of TRUE, FALSE, Y or N in B2:N):
=arrayformula((trim(transpose(query(transpose(iferror(regexreplace(regexreplace(text(B2:N,),"(FALSE)|(N)",),"(Y)|(TRUE)",if(A2:A="A","Good",if(A2:A="B","Best",))),)),,columns(B2:N))))))
Alternative where values in B:N are either 0 or 1:
=arrayformula((trim(transpose(query(transpose(iferror(substitute(substitute(B2:N,0,),1,ifs(A2:A="A","Good",A2:A="B","Best")),)),,columns(B2:N))))))
B2:N is the range of cells to process.
The inner SUBSTITUTE clears all 0 values.
The outer SUBSTITUTE swaps 1 values for a test to see if values in A contain "A" or "B".
IFS does the test and returns either "Good" or "Best".
IFERROR hides any #N/A values down the sheet where the rows are empty.
TRANSPOSE transposes the data for QUERY.
QUERY is used to collapse empty cells (vertically). columns(B2:N) is used in the header part of QUERY. This is a quirk of QUERY, where the header number >= the columns of data, QUERY does the collapse.
TRANSPOSE reverts the dataset to the previous orientation.
TRIM removes leading or trailing space.
ARRAYFORMULA allows the formula to automatically cascade down the sheet, rather than you needing to drag the formula down (like with =IF(AND({B2:N2}>0, A2="A"),"Good", "")).
So, you already have this partial solution. To get a second condition to be met before printing something to your cell, just add an AND() with a new COUNTIF(), comparing A column with A, and then at the else argument, repeat your original IF(), just changing A for B and the output for each case. I will look like this:
=IF(AND(countif(A2;"A");OR(countif(A2:N2;"Y");countif(A2:N2;TRUE)));"Good";
IF(AND(countif(A2;"B");OR(countif(A2:N2;"Y");countif(A2:N2;TRUE)));"Best";"BAD"))
To use it on every row, just autofill the column O. The row numbers will change accordingly and work on its own.
If you need a new if() statement for a third or fourth case, just repeat it, nesting one IF() inside the other, leaving room for a default error message at the end.
first of all excuse my poor English, I'll try to explain myself better as I can.
I find hard to explain and summarize my problem, but here is it:
I have a range of cells in a Google Spreadsheet (almost a column, name it A) with some values, mixed, all numerical, but with some cells with no values. Empty values may change over time. The right column (name it B) show a series of values, with decremental order. The rows of the table can change position automatically considering this last column, so if we put a value in the column A it may modify the sum of B column and then, the =SORT() formula will reorder rows and place it somewhere else.
A B C
5,2440
6,6000 6,8740
5,3442 6,7000
6,4500
5,3000 5,2440
5,2152
6,9000 5,0423
3,7600 4,9523
4,8240
4,6745 4,6123
The question is that I need the cell in column C to show the value of the B column corresponding to the fourth cell with content starting from the last one. In this case, is the cell with value 5,3000 at column A, so, the result to show is 5,2440.
Consider if somebody set a value at last empty cell (5,0000, for instance), and the =SORT() reorder the list and I get this:
A B C
5,2348
6,6000 6,8740
5,3442 6,7000
6,4500
5,3000 5,2440
5,0000 5,2348
5,2152
6,9000 5,0423
3,7600 4,9523
4,6745 4,6123
Now, the fourth cell with a value starting from the last one is the one with 5,0000, so the cell in column C has to show 5,2348
I've tried to make it possible with =VLOOKUP(), and =MATCH(), but I know that may cause problems if there are same A values repeated (and in my big table there are many repeated values in that A column). I know how to make a =OFFSET() to get a value starting from a specific row, but I've no idea to how to tell Spreadsheet to count and look for something backward.
Thanks in advance, all ideas will be much appreciated
=QUERY(A3:B, "select B where A is not null limit 1 offset "&COUNTA(
QUERY(A3:B, "select B where A is not null", 0))-4, 0)