Compare and Multiply - google-sheets

I want to compare two cells and obtain a percentage, for instance:
A1 is 190
B1 is 200
C1 is the answer
I tried:
B1 >= A1
but the answer is TRUE.
I will create a report if cell B1 s greater than cell A1 then:
IF YES I need to get the 12% percent of cell B1 and the answer would appear on cell C1
IF NOT the value for cell C1 would be 0.00.
Can anyone help me to create a syntax for that?

Try =IF(B1>=A1,B1*0.12,0)
check snap below
And for formatting you can select column, right click - Format Cells - select Number and keep 2 Decimal places.

Related

Continuous total from only one cell to another as it grows

I am hoping to calculate a total as is grows or decreases using only 1 row and only 2 cells in this row. I'm wondering if it this is even possible with a formula (not a script):
Scenerio:
A1 and A2 have a Value of 0
(A2 is the running total of A1, whenever a number is entered into A1 and Enter is pressed, this number will add to the value of A2)
A1 has 2 entered into it and Enter is press (Cell changed)
A2 adds this to its 0, becoming 2.
A1's 2 is deleted, but A2 remains 2.
A1 has 3 entered into it and Enter is press (Cell changed)
A2 becomes 5
(The only way to add or subtract from A2 is enter - or + number into A1, otherwise A2 remains the current total)
I hope this is clear. I would like all things isolated to a single row, so a normal running total does not work for this case.
To be able to accomplish this task you will need to adjust your Spreadsheet settings.
For your specific case scenario where you just want to add (or subtract) only once the value of A1 to A2 you would need to head over your Spreadsheet menu bar and select File->Spreadsheet Settings-> Calculation. In that tab you should turn on Iterative calculation and set the Recalculation to on Change and the Maximum number of iterations to 1 .
Finally set A2 formula to be = A1 + A2. Every time you change A1 its value will be added (or subtracted if it is a negative value) to A2.
Reference
Choose how often formulas should recalculate

COUNTIF with absolute column, relative row in Google Sheets

I have this table and I want B1 and B2 to display the sum where D1, F1 and H1, and D2, F2 and H2 are bigger than 0, respectively. I will be inserting two columns to the left of C on a regular basis, and I don't want the column references in the formula to be updated when the columns are shifted, but if B2 becomes B3 when a row is added above it, I will need the formula to be updated for the row and check the values in D3, F3 and H3, or if I add rows below it, I want to be able to drag down and get the formula copied with incremental row values. I tried INDIRECT with and without &CELL("address", E2) but I couldn't get it to work as I wanted it.
A B (Sum) C D E F G H
1 Josh 3 Some number 6 Some number 4 Some number 3
2 Fiona 2 Some number 1 Some number 0 Some number 4
You can use OFFSET to get absolute column references, and COUNTIF to count if each referenced cell is bigger than 0:
=COUNTIF(OFFSET(B1,0,2),">0")+COUNTIF(OFFSET(B1,0,4),">0")+COUNTIF(OFFSET(B1,0,6),">0")
Not perfect, but try =SUM(OFFSET(B2,0,1,1,500)). That way you refer to the cell itself so whenever you add columns it's not affected. I used 500 arbitrarily since it's simple. Adjust as needed.

Change the colour of a cell based on another cell value

I am trying to create a pixel art activity where a specific number in a cell will turn a different cell a colour if the correct answer/ number is input.
For example if cell C2 has the correct answer of 7 then cells E1,F2, and G3 would turn Red.
Then if cell 2 has the correct answer of 22 cells F1,G2, and E3 would turn blue. But any other number would not change the colour of those cells.
try like this with custom formula:
=$C$2=7
welcome to stackoverflow.
For example in cell C2 apply this rule
Format cells if: 'Custom Formula is' (dropdown)
= E1 = 7
now C2 should get formatting when E1 equals 7.
Note that for strings you will need to use double quotes, like this:
= G2 = "k"
Finally, if multiple cells need the same rule, you can click the squares icon in the 'Apply to range' input field, and then you can hold 'control' and click multiple fields.

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

If statement contingent on data from 2 cells

Using Excel 2010 I need a formula that will respond to data in one cell, and differently to data in another.
Cell A1 = Date
Cell A2 = Invoice Dollar Value
Cell A3 = Discount (formula to remove 15% from A2)
Cell A4 = Refund amount
Cell A5 I want to read... if there is a date in A1, then A2 - A3, BUT if there is a value in A4 then A4 - A2 (note, if there is a value in A4, there will not be a value in A2)
I have tried the following...
=IF(A1<>"",(A2-A3),"",If(A4<>"",A4-A3,""))
So my goal is to have the spreadsheet calculate Invoice amount minus any discount. And in the same cell calculate refund amount minus any discount.
Your outer IF statement isn't quite right. The structure is
IF(Condition,<execute this when true>,<execute this when false>). But you're putting 4 parameters into it.
Try =IF(A1<>"",(A2-A3),If(A4<>"",A4-A3,"")) instead.
NB: This only checks that cells A1 & A4 have values, not that they are of a specific type, i.e. it it isn't checking that A1 has a date.

Resources