Use text in a cell as plus and minus - google-sheets

I have a sheet with multiple rows. There is a cell on each row that says "In" and "Out" in a dropdown. Basically this is plus and minus. Next to that I have a cell that that holds an amount.
So it looks like this:
Item 1, In, 10
Item 2, Out, 5
This totals a profit of 5.
How can I with this setup calculate the total profit/loss for all the cells in the sheet depending on multiple in/out rows?

An if formula will calculate the rows and a sum formula will calculate the column.
First make the numbers positive and negative values.
=IF(B2="In",C2,C2*-1)
This formula in 'D2' checks if the value of 'B2' is "In".
If yes then just adds the value of 'C2'.
If no then it multiplies the value of 'C2' by negative one.
Second step is to add up the numbers.
=SUM(D2:D3)
Cell 'D4' sums the column.

Related

how could I count minus cells in a column excluding the last one?

I want to count on another sheet that how many people have a minus balance. Of course, I should use COUNTIF, but how could I dynamically narrow the range from C2 to the second last non-blank cell(because there's a chance for the total balance to be minus, it should be excluded)?
Try below formula-
=COUNTIFS(C2:INDEX(C2:C,COUNTA(C2:C)-1),"<0")
Here C2:INDEX(C2:C,COUNTA(C2:C)-1) will return a array of values as well cell reference from C2 to last second non empty cell in column C (Assume you do not have any blank rows inside data). If you have blank row, then you have to use different approach. See this post by #TheMaster
COUNTA(C2:C) will count all non blank cells in C column then minus 1 from that count to make it second non empty cell till down to up.
And then apply COUNTIFS() function.

Repeating cell based on X values on a row and move to the next row and do same process

I have this data and each row contains X row number in a cell, so I want to repeat the email and other values on the row based on the X number in the cell.
so for example, if the X value is 0 I don't want this row to move to the other sheet, but if the value is 4 I want to have to the other sheet 4 times. and then continue with the next rows.
I actually could achieve this but the issue is that I don't know how to make the formula move to the next rows and do the same process.
Link for the sheet: https://docs.google.com/spreadsheets/d/1VbOyaMfsbS6Yoz9xUqfNkLqmPyzMxd-K97Dc7vywLm0/edit?usp=sharing
Your help is highly appreciated.
I've added this formula in I6 of your sheet:
=ArrayFormula(TRANSPOSE(SPLIT(TEXTJOIN("", 1, REPT(C6:C10&";", D6:D10)), ";")))
See if this is what you are looking for.

how can i make google sheet itrate over columns

I have a sheet like this how can make a cell in front of x under the sum column get the sum of the x count column and y get the sum y count column
of course, I use sum function on both but the issue I face is how to make the z ,x1,y1,z1 the same I try to fill it down but as you see in the picture it is wrong
how can I do it for 100 row ?
This formula seems to give the result you want:
={"Header","Sum";
ARRAY_CONSTRAIN(TRANSPOSE(D1:1),COUNTA(D1:1),1),
ARRAYFORMULA(MMULT(TRANSPOSE(N(D2:AJ10)),{SEQUENCE(ROWS(D2:AJ10),1,1,0)}))}
It places the two column labels in the first row, then transposes all of the header values into a vertical column in A2:A, but prevents any blank rows by using ARRAY_CONSTRAIN, and a check for the number of header values to transpose.
The main result is the Sums, calculated using MMULT. You need to enter the range of the cells you are going to sum over - I've used D2:AJ10, entered twice in the formula. MMULT can slow down performance the more cells it has to review, but this seemed fine for 33 columns by 9 rows. Test it out in your actual sheet, and report back if any issues.
REFERENCES:
ARRAY_CONSTRAIN To limit size of an array result, by # rows and # columns
MMULT The matrix product of two matrices. Can be used for summing, if one matrix is one dimensional (eg. a row or a column) with values of just 1.

Count row once if it contains "A"

I have four columns of data. I want to count the row once if any of the four cells in each row contains an "A".
Here's a sample sheet: https://docs.google.com/spreadsheets/d/10hZuOgdL3Pf3-yLsK1G4DlVIThGR0fWBL_IEMpn5vnY/edit?usp=sharing
You can use
=ArrayFormula(sum(N(mmult(n(regexmatch(B4:E15,"A")),transpose(column(B4:E15)))>0)))
or
=sumproduct(N(mmult(n(regexmatch(B4:E15,"A")),transpose(column(B4:E15)))>0))
to get the row totals and count the ones which are greater than zero.
This is case sensitive.

Formula to find last value in row and label with Column Top

I'm using Google Spreadsheets. I'll be using this image from a very similar question.
http://i.imgur.com/jqcNW.png [a link]Google Spreadsheet Formula to get last value in a row
Instead of giving the value, I want the Column top to show. So the H column would look something like: 2 1 3 1 4
(The product numbers from Row 1)
If it helps =index(B2:G2;1;counta(B2:G2)) was the answer given to the original question. My values would be words instead of numbers. It'd need to track the last 'Yes' in the row with the column top being dates.
I think this should be easy:
=index($B$1:$G$1;1;counta(B2:G2)) - if you write this to the H2 cell, it should search the "N"th element in the FIRST row ($B$1:$G$1) - where N represents the value of non-empty cells in that row (B2:G2).
You can then populate this H2 formula downwards.
Let me know if this helps.

Resources