Google Sheets - Multiply field by field three to the left - google-sheets

My title might not be very specific, so I'm going to try to explain a little better.
The sheet is divided into a name(Column A), containing a certain number of values(Column B), that get added together to a total in Column C. Furthermore, Column D, E and F contains the values I want the Total in Column C multiplied by. These first columns A to F I just fill in manually, but I would like a function to calculate the Columns I've called x, y and z total (G, H and I).
I see a pattern in this, I just can't figure out the syntax to get Sheets to see it aswell.
The pattern I'm invisioning is for each row, I want column G, H and I to take the value 3 fields to their left, and multiply it by Column C, at their row number.
Is this somehow achievable? I tried finding a solution online but I guess I don't know how to word myself.
Here's a picture to maybe make everything a little clearer
This would save me alot of time, given that I have over a hundred different rows this calculation needs to be performed on...
If something is not clear, please feel free to write a comment. I'll be following this thread quite liberally.
Thanks in advance!

You can have this formula on the first xTotal:
cell G2: =ARRAYFORMULA(if(len(C2:C),C2:C*D2:D,))
cell G2: =ARRAYFORMULA(if(len(C2:C),C2:C*E2:E,))
cell G2: =ARRAYFORMULA(if(len(C2:C),C2:C*F2:F,))
I created a sheet with the same results you had before, but this time you don't need vertical columns, just say in the # of Values column how many numbers you should have below. You just need to input the values with the grey columns.
Note: This is assuming you will always have growing vertical numbers like 1,2,3,4,5. In the new sheet you just need to set 5 in the column and it will calculate the result.
Please make a copy of this sheet and edit as you wish.
Sheet

You can use a single, simpler formula for this in cell G2
=ARRAYFORMULA(if(C2:C="",,C2:C*{D2:D,E2:E,F2:F}))

Related

change output cell based on different cell's value

I'm creating a spreadsheet about my paylog.
I want to have a sum where it tells me how much still needs to be payed out based on if the box next to it is y or n (y=payed out, n=payed out, which means go into the sum box)
After viewing that, this should be the result.
Based on that info then I would change up a few different things to avoid the circular dependency. For your total formula, I would use as SUMIF: =SUMIF(B:B,"n",C:C) That will only count the values in column c if column b is equal to "n". Next I would use conditional formatting to change the font color to white for all values in column c when column b is equal to "y". I've provided a demo sheet so you can view the results. This will allow you to have values in column c which will remove the circular dependency issue. Feel free to make a copy to be able to view the editable version.
Demo Sheet here
I'm sure there are many other ways to accomplish your goal but without more info...that is a direction I would go.

How to Transpose Rows to Columns Towards Left Columns? In Google Sheet

SECOND IMAGE CLICK NUMBER 1 I Want To Transpose Row Value Range A2:A50 To Column CZ2 To BC2. Formula Should Be Given IN CZ2. AND VALUE SHOULD GET IN REVERSE OR LEFT COLUMNS.[First IMAGE Click Number 2] 2. If I Give Transpose (AO2:AO50) In CZ2 it Will go range from CZ2 To EW2. I Want Transpose in Reverse Columns. If I Increase Row Value AO2:AO60 It Should Flow Towards Left From CZ2 To AS2. I Mean Transpose Should work towards Left Side Columns. Its Ok with any other formula If Not Transpose. Hope My Question is Understandable. Someone Help Me Out. Thank You In Advance.
It's not clear why you would want to do this. However, the end goal can be achieved by placing the following formula in cell B2 (not CZ2):
=ArrayFormula(IFERROR(VLOOKUP(COLUMNS(B1:1)-COLUMN(B1:1)+ROW(A2)+1,{ROW(A2:A),A2:A},2,FALSE)))
Try it and you'll see what I mean.
The formula is written to be flexible. So if you add or subtract data from A2:A, the value in A2 will always be in Row 2 of the last column to the right in the sheet; and all other values will work backward from there.
If you always want to start to backward progression in Column CZ and Column CZ is not (or may not always be) your rightmost column, you can use this version:
=ArrayFormula(IFERROR(VLOOKUP(COLUMN(CZ1)-COLUMN(B1:CZ1)+ROW(A2)+1,{ROW(A2:A),A2:A},2,FALSE)))
Just understand that, if you don't have columns at least through Column CZ, this formula will fail to work as expected.
I recommend using the first formula I supplied above, since it will always work, no matter how many columns there are, filling backward as far as to the formula column (B2) as needed.
Understand also that if you have more than 103 rows of data in A2:A, that would be more than could fit between B2 and CZ2; so only the first 103 would be displayed.
ADDENDUM (after reading first two comments below):
The principle is the same if you want to run results from "CZ to BC"; only in this case, you want to limit the results to no more than 50.
Place the following formula in BC2:
=ArrayFormula(IFERROR(VLOOKUP(SEQUENCE(1,50,ROW(A2)+50-1,-1),{ROW(A2:A),A2:A},2,FALSE)))
To reiterate, you cannot run formulas that will fill or columns backward. (Even if the sheet is set to right-to-left font with Column A appearing at the far right, the formula is still filling A-Z according to that setup.) However, if you know that you want a 50-column range reserved and you want the answers to go backward, this can still be achieved by placing the formula in the first of the 50 columns rather than the last, as I have proposed above.

Count number of times values increase in range - Google Sheets

how are you? I'm just not sure what to do here, but I surely can use your help!
I have a series of values in a row range, such as in the following:
1000 2000 1500 2100 3200
I need to figure out a google sheets formula to put in the 6th cell of this row that counts the number of times the value of any cell is greater than the one to the left of it. In this example, my result should be 3.
Is there any way that this can be done? In Excel or Google Sheets, either is great to learn.
Thank you
You can also try the following formula
=COUNTIF(QUERY({{"";TRANSPOSE(B2:F2)},{TRANSPOSE(B2:F2);""}},
"select Col1-Col2 offset 1 label Col1-Col2 ''",0), "<0")
Assuming you have data in A2:E, place the following in F2:
=ArrayFormula(IF(A2:A="",,MMULT(IF(B2:E>A2:D,1,0),SEQUENCE(4,1,1,0))))
Since there are only four columns that might be greater than others (B:E), you can structure it this way. MMULT is hard to explain, but it essentially multiplies everything in each row of one matrix (range) by everything in another range and then adds them. SEQUENCE just forms a column of four 1's by which to multiply then add together everything in each row of the first range. Since anything times 1 is the original number, this just serves to to row-by-row addition.
This formula will process as many rows as have data in A2:E.
try in 7th column on row 2:
=ARRAYFORMULA(MMULT(IF(A2:E4<B2:F4, 1, 0), {1;1;1;1;1}^0))

Counting the Number of Empty Cells between Non-Empty Cells in Google Sheets

I'm trying to count the number of empty cells that exist in a column between each non-empty cell but haven't been able to work out how.
Using this, I'm also trying to find the largest "empty distances" and locate the cell in the center of these distances.
The sheet I'm working with lists a set of marker colors and denotes the ones that are owned out of the full set of colors. I'm trying to find the largest ranges of missing colors and then find the colors in the middle of those ranges in order to find a handful of markers that would best help to fill out the spectrum.
Columns 1-6 are information- Column 7 marks whether the color is owned:
I may have an answer that helps you.
I could only get it to work using a helper column, but someone may know how to eliminate that requirement.
The helper column creates an array, basically listing the row numbers of the rows that have an "x" in your column B.
The main formula then measures the gap between each of these listed row numbers. It also checks the gap before the first "x", and after the last "x". Note that I have the data starting on row 2, which complicates the formula, but makes the sample sheet clearer - this can easily be changed to row 1 if you prefer.
={F2-1;
query(ArrayFormula(if(isnumber(F3:F),F3:F-F2:F-1,"")),
"select Col1 where Col1 > 0",0);
counta(A2:A)-indirect("F"&COUNTA(F$2:F))}
See a sample sheet here:
https://docs.google.com/spreadsheets/d/19QUFGRqTT6BqOsBrEBpTIxQCeNdRa5mzXhxQpCZ8sV4/edit?usp=sharing
Then I used a second formula to calculate the max gap between "x"s, (or before the first or after the last x).
Note that calculating the midpoint of the gaps, and doing a lookup of the corresponding mid-point colour, is something that can be added to this answer, if you share a sample copy of your sheet and share it for editing.
Let me know if this helps. I'll add more explanation to describe what the formula is doing tomorrow.
And I'll provide a second tab with the formulas adjusted to work with data beginning on row 1.
You can also get the lengths of the gaps using Frequency:
=ArrayFormula(frequency(if((B1:B20<>"X")*(A1:A20<>""),row(B1:B20)),if((B1:B20="X")*(A1:A20<>""),row(B1:B20))))
but finding the centres of the gaps and allowing for equal-sized gaps is more difficult.
This should find the position of the "X" at the end of the longest gap:
=ArrayFormula(
sum(frequency(if((B1:B20<>"X")*(A1:A20<>""),row(B1:B20)),
if((B1:B20="X")*(A1:A20<>""),row(B1:B20)))*(sequence(countif(B1:B20,"X")+1,1)<=
match(max(frequency(if((B1:B20<>"X")*(A1:A20<>""),row(B1:B20)),
if((B1:B20="X")*(A1:A20<>""),row(B1:B20)))),frequency(if((B1:B20<>"X")*(A1:A20<>""),row(B1:B20)),
if((B1:B20="X")*(A1:A20<>""),row(B1:B20))),0)))+
countif(sequence(countif(B1:B20,"X")+1,1),"<="&
match(max(frequency(if((B1:B20<>"X")*(A1:A20<>""),row(B1:B20)),
if((B1:B20="X")*(A1:A20<>""),row(B1:B20)))),frequency(if((B1:B20<>"X")*(A1:A20<>""),row(B1:B20)),
if((B1:B20="X")*(A1:A20<>""),row(B1:B20))),0))
)
and then it should just be a case of working backwards from there to the centre of the longest gap. However the formula needs further refinement to deal with the cases
(1) Where the longest gap is after the last "X"
(2) Where there is a tie for the longest gap
(3) Where there is a need to list the longest, second longest, third longest gap etc.

Google Sheet Sum Row: Count if above or below criteria

I am trying to create a summary row in a google sheet that tallies up how many cells met their criteria. These criterion are set in 2 columns to the left; Column C is the "Goal" column, which has the goal number. Column D is the "MinMax" column, which determines if that goal number is the min or max.
For example, if the Goal is 5 and the MinMax is Max, then the goal is 5 or less (5 being the maximum number allowed).
I already have successfully created conditional formatting for this sheet, which looks like the following:
=IF($D4="Min",E4>=$C4,E4<=$C4) | Turn cell green
I am struggling to find a way to use a similar calculation for the Summary row. I feel like I might need an array formula, but I'm not sure how to set it up.
If you want to count the values try:
=if(D2="Max",countif(E2:E,">="&C2),countif(E2:E,"<="&C2))
If you want to sum them useL
=if(D2="Max",sumif(E2:E,">="&C2),SUMIF(E2:E,"<="&C2))
I actually figured out a formula!!
=countif(ARRAYFORMULA(if($D$4:$D$19="Min",E$4:E$19>=$C$4:$C$‌​19,$C$4:$C$19>=E$4:E‌​$19)),true)-countif(‌​E4:E19,"N/A")
I had to go back into the data and change the blank cells to "N/A" to make it work, but it works!!

Resources