Summing over values in Google Sheets after applying a formula - google-sheets

I have a column of strings of the form
n|m
where n<m are natural numbers and I want to calculate the sum of this column where each cell has value m-n (m minus n). I can calculate the respective values into a separate cell via:
=INDEX(SPLIT(A1,"|"), 0,2)-INDEX(SPLIT(A1,"|"), 0,1)
and sum over those but I would like to do it in one step just as one formula below the specified column in one cell. Is that possible?
Thanks

Try in B1
=ARRAYFORMULA(SUM(IFERROR(INDEX(SPLIT(A1:A,"|"), 0,2)-INDEX(SPLIT(A1:A,"|"), 0,1))))
if you want to get the sum below the last value, i.e. row#8
=ARRAYFORMULA(SUM(IFERROR(INDEX(SPLIT(A1:A8,"|"), 0,2)-INDEX(SPLIT(A1:A8,"|"), 0,1))))

Related

Conditional Formatting formula to compare two cells when one cell has a delimiter

So I have in column D QtyInvoiced and in column G QtysSent. For each row, QtyInvoiced is a single number e.g. 50. QtysSent on the other hand is of the delimiter format A_B_C where A,B and C are quantities. In each case, A+B+C would be the Total QtysSent.
How can I write a conditional formatting formula that compares (in the example above), the single value 50 in column D to A+B+C and higlights both cells in the particular row if they are not equal?
I imagine it requires using SPLIT inside the formula but not sure how to construct it to tell Google Sheets to compare the sum after splitting to the value in column D and then highlight both if they are not equal.
try this out:
Custom formula:
=$D2<>SUM(SPLIT($G2,"_"))

Implement formula in a column based on contents of each cell

In my Google Sheet, I have 1000+ rows of Date entries. For each Date, I am calculating the Month# and Week# using MONTH() and WEEKDAY() functions respectively.
Here is the link to a sample file: https://docs.google.com/spreadsheets/d/1Af5-pYMFWZ1QtLoaAbPZYMGRvk43JBslUp4KyOFADfA/edit?usp=sharing
Problem Statement:
For all rows which have a unique Month# and Week#, I would like to implement a formula and calculate Output. For example, in my sheet, rows 3 to 6 pertain to Month=1 and Week=4. For this set of 5 rows I am calculating Output column as the subtraction from the first element in that set (ie... C3-$C$3, C4-$C$3, C5-$C$3 so on ). Similarly row 7 to 10 pertain to Month=1 and Week=5, and so I calculate Output
as Data-$C$7 and so on.
How do I implement this structure to calculate Output column on each set of unique Month# and Week# values?
Delete everything from Column F (including the F2 header). Then place the following formula into cell F2:
=ArrayFormula({"Output";IF(C3:C="",,IFERROR(C3:C-VLOOKUP(E3:E,{E3:E,C3:C},2,FALSE)))})
This one formula will create the header and return results for all valid rows.
Since VLOOKUP always finds only the first matching instance of what it is looking up, we can use it to ask that each value in C3:C subtract that first instance of where week-number match for each row.
By the way, although you didn't ask about this, you can also use this type of array formula in Columns D and E, instead of all of the individual formulas you have. To do that, delete everything from Columns D and E (including the headers). Then...
Place the following formula in D2:
=ArrayFormula({"Month #";IF(B3:B="",,MONTH(B3:B))})
... and the following formula in E2:
=ArrayFormula({"Week #";IF(B3:B="",,WEEKNUM(B3:B))})

How to use IF AND statement with range of cells google sheets

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")

Formula to give itemized sum

I have the following sheet (link). What formula would yield the itemized sums in B2, C2, and D2?
To calculate the value in B2, the formula should check cells B5:B10 and sum the corresponding values from A5:A10 for non-blank cells. Hence: 30+45+30=105.
I have tried ARRAYFORMULA(IF(B5:B10 != ""), sum(A5:A10)) which results in Formula parse error.
Considering that the numbers in column B are not to used (thats what i figured out from your example).
you can use sumIf:
=SUMIF(B5:B10,">0",A5:A10)
so this will check if the cell in column B is greater than 0, then it will add its corresponding value from column A.
please note that if you put a character in the B column the SUMIF will not consider it because we are using ">0" as criterion, instead use ISBLANK.
hope it helps.

Google Sheets - Multipling a cell(weight) by another(rate) based on its value compared to a column of cells

I want to compare the value of cell(K5) against column A to determine the range its rate will fall under. Once the proper rate is determined, I want to multiply that row with its values on column B, C, etc and output it on cells (L5, M5, etc)
for example if the CW(K5) is 755.5 then its range falls under cell A8(500+) so we can multiply CW(K5) by B8 and C8 and output the product on L5, M5 respectively.
Eventually I will have many more rows so is probably a better idea to have rates(columns A, B, C) in a separate sheet, is that even possible?
the actual sheet
I've made similar data sheet, but removed strings with actual numbers to look for in column A. And then used vlookup for sorted range A:C:
The formula for F2 is:
=VLOOKUP(E2,$A:$C,2)
The formula for G2 is:
=VLOOKUP(E2,$A:$C,3)
This technique may help you.

Resources