A "constant" in google spreadsheet? - google-sheets

Say I have 2 columns: (this is extremely simplified)
Data = a number
Result = Data * 1.2
I can put B2 = A2*1.2, then drag and drop B2 down...
and it fills all the other cells, which is perfect.
But can I put this multiplier (1.2) somewhere as a "constant"? (for clarity and being easily editable)
Say I put it in E1, and set B2 = A2*E1.
Now I can't drag and drop anymore (because E1 becomes E2 E3 and so on)
In this example, is there a way to make E1 stay as you drag it down?

Short answer
Use an absolute cell reference or a named range
Explanation
Instead of E1, which is a relative cell reference, use $E$1 which is an absolute cell reference.
An alternative is to to assign a name to the cell E1, let say, "constant"
In the first case the formula will be
=A2*$E$1
In the second case
=A2*constant
References
Spreadsheet - Wikipedia
Name a range of cells - Google Docs Editors Help

I understand that you are asking for "A “constant” in Google spreadsheet?" and later on a "drag down" solution.
You can use the accepted answer, OR ...
Instead of having to drag down (increasing the number of formulas)
Use a single formula in B2
=ArrayFormula(A2:A6*E1)
You can even use it for future entries or now blank cells.
=ArrayFormula(IF(A2:A11<>"",A2:A11*E1,""))
How the formula works
The ArrayFormula will apply the calculation cell*E1 in every single row, IF the cell is not empty/blank "".
IF it is a blank cell it will return a blank cell "".
Functions used:
ArrayFormula
IF

Can you try this in your formula?
Cell B2 type
=A2*$E$1
Then there is no need to drag it down on column E, it will all follow E1.
I believe this solves the problem.
If you really want to drag it down, then why not just put Cell E2
=E1
So that even when you drag, the value will remain 1.2

Related

Conditional formatting if cells in row are less than header

I am trying to find a way to have a cell in column A turn yellow if any cell in the adjacent row is less than the value of its corresponding header. Please see my example sheet.
I'm trying to use this formula for my conditional formatting: =COUNTIF(B5:5,"<"&B$4)>=1 but I believe it's stuck on using Cell B4 as the header value for the entire range (instead of C4 for column C, D4 for column D, etc).
Any ideas on what I'm missing here?
For the red option, as you suggested, you should use:
=COUNTIF($B5:$H5,"")
But you may keep it that option above, so it is red even if there's an orange
Then, for yellow you can use:
=COUNTIF(BYCOL($B5:$H5,LAMBDA(each,each<OFFSET(each,4-ROW(each),0))),TRUE)
It checks in each column if the value is smaller than in row 4, and counts the amount of TRUE values
And green should be by default, I understand. Is it useful?

How to reference an adjacent cell in google sheets relative to the selected cell

I am trying to use the =sum() function in google sheets, and so far, that's all I have typed into the targeted cell. For example, I want D3 to be the sum of C2 and D2. I know how to type that. =sum(C2,D2). But I want cells D3 thru D30 to have the same equation, relative to their adjacent cells. Something like this =sum(cell to the left, cell above). Let me know if you need more elaboration, or if you have the answer, great!
Solution
Paste this formula in the first cell next to your numbers or take a look at the Example Sheet
=IF(C2="",,IF(ISNUMBER(D1),C2+D1,0))
Explanation
We check the above cell ISNUMBER if so we calculate C2+D1 if not we put 0
IF(C2="",, to calculate onlt when the range C2:C is not Empty.
If you are looking for a single formula you can also try
=INDEX(IF(ISNUMBER(C2:C), SUMIF(ROW(C2:C),"<="&ROW(C2:C),C2:C),))

Google Spreadsheet: E2-F2 even if i move the rows

I'm having an issue with google spreadsheets. I want to... have Cell C2 always contain the difference between cell E2 and F2 even if I move the row (i don't want the formula to adapt to that change of rows, the formula should still be E2-F2); so let's say E2 contains 5 and F2 contains 3, C2 would display 2. So let's say I switch row E and row F. Right now the result displayed would still be 2, and the formula in cell C2 would've changed to F2-E2. What I want is the formula not to change, and the result displayed would be -3.
=INDIRECT(E2)-INDIRECT(F2) didn't work for me - it gave me a reference error.
The INDIRECT function expects a string parameter. So you would need to write
=INDIRECT("E2")-INDIRECT("F2")
But the better way to solve your problem would be to use absolute references
=$E$2-$F$2

Making Conditional Formatting for a SUMIF filter in Google Sheets relative?

I have a handy little Google Sheet formula that applies a color given a summed total but I can't get that formula to be relative. I suspect this is either an easy genius fix or currently impossible in Sheets. Any help?
Sorry I can't post images, here's a rough simulation of my table a1 - b4
John Doe | 25%
Martha Roe | 25%
John Doe | 75%
Jane Doe | 25%
In the table above, I'm using Conditional formatting to "Format cells if..custom formula is..." and my formula sums up the values in Column B for John Roe and Martha Roe (Column A) and turns both the name and value cell red if that value exceeds 100%. I use the formula below:
=sum(filter(B$1:$B4,A$1:A$4 = A1)) >= 100%
(Full credit to Spreadsheetpro.net's article for the intro SUMIFS, COUNTIFS, & AVERAGEIFS functions in Google Spreadsheet.)
Unfortunately, when I use this conditional formatting approach and drag that formula to the next cell in the row, it still thinks I mean A1 (not A2); it's just applying that original formula to multiple rows. So right now I need to manually change the formula for each cell. Maddening.
What I'd like to do is have it update relative to what cell it's in. To make it easier, I'd be ok if there was a way to tell it in the formula "use the cell I'm in" (instead of specifying A1).
Is there a way I can fix my current formula so Google knows that A1is relative? OR, barring that
Is there a way to use conditioning formatting with a formula so it knows the use the current cell in the formula?
Thanks!
The trick is to not drag the formula per se, but apply it to the range you require. The formula will be propagated across that range, respecting absolute and relative references as if you were dragging an in-cell spreadsheet formula over a range.
In your case, I think you just need to apply:
=SUM(FILTER($B$1:$B$4,$A$1:$A$4=$A1))>=100%
to the range A1:B4.
It can help conceptualise what is going on by just plugging that formula into a spare spreadsheet cell, and dragging it over a 2x4 range of cells.

Automatic cell math google spreadsheets

I am working on a stats tracker for a game using a Google spreadsheet and as you can see in the linked image below, D2 is subtracted from D3 to give F3 a value. The E and G columns have the same relation.
My issue is, while the formula is simple (i.e. in F3 type, =d3-d2 , to get a value), typing this formula 100 times altogether is a bit mundane.
Is there anyway that I can have this done automatically? I have more features I'd like to add, but I am holding off because of this issue.
Hopefully this link works, I don't have enough rep to post an image. http://imgur.com/cyh27np
You do not need to type the formula for each cell, you can just select the cell, copy it and paste it on the cell below. The cells referenced are relative to their position so they will change accordingly.
For example in your case, if you select and copy cell F3 and paste it on cell F4 you will see that the pasted formula will actually be =D4-D3
Just left-click in the bottom right-hand corner of the formula you want to copy (or even number sequence), and drag it down or across however many cells you like. The program will recognize the pattern and continue it accordingly.

Resources