For a spreadsheet idea i wanted to make a point based system depending on how many calories were consumed within a day, to do this I wanted to do a range style system
I know in OOP languages you would take a variable, and do an IF ELSE (or switch) statement, but i'm not quite sure how to do it in a spreadsheet
=IF(D11<900,"-200"),=IF(D11<1200,"200"), =IF(D11<1500,"0")
In this code i wanted it so that, if less than 900 calories are consumed, there will be a 200 point penalty, and then from 900-1200 calories there is 200 points granted and then from then on like that
Nest the IF
=IF(D11<900,-200,IF(D11<1200,200,IF(D11<1500,0,"Greater than 1500")))
try:
=VLOOKUP(D11, {0, -200; 900, 200; 1200, 0; 1500, "GREATER THAN 1500"}, 2, 1)
see: https://webapps.stackexchange.com/q/123729/186471
Related
Okay, say I have 5 cells. Each with varying amounts.
I want a function that: If(Sum(b2:b6) {greater or equal to a multiple}, True, False
So every time the total value of those cells is greater to or equal to a multiple of, say 50, so if it lands on 50n+1 or something, it'll react as if it hit 50n.
I guess you are not multiplying but adding numbers in range, since you are using "SUM" in function. In case, here is a solution:
=IF((SUM(B2:B6))>=50;TRUE;FALSE)
Note: This code is written with Norwegian format settings. Change ";" in formula with "," for American format settings.
sounds like:
=IF(SUM(B2:B6)>=50; 50; )
I have a table like this. I want to draw a chart as X:Time and Y:Amount. Is there a way to do that?
EDIT:
As per #doubleunary's comment, here is an editable sheet with what I exactly want. If I try to explain the use case to make it easy to understand, let's say I get paid for services I offer for different time ranges. Now I want to draw a chart to show the real daily income I got. Hope it's clear.
https://docs.google.com/spreadsheets/d/1AjG5zaz59ryCndvoutgLXrHQq2YF7FKjdJRR316UyrE/edit?usp=sharing
Use the sum(filter()) pattern, like this:
=sequence( max(A3:B9) - min(A3:B9) + 1, 1, min(A3:B9) )
=iferror( 1 / sum( filter(E$3:E$9, A$3:A$9 <= A11, A11 <= B$3:B$9) ) ^ -1 )
See the new Solution sheet in your sample spreadsheet.
The iferror(1/()^-1) pattern ensures that cells where there is no result remain blank.
I've seen a hundred questions with the same 'title', however I can't figure out the right answer for my problem (or maybe it gets too hard for me).
It's about a Dungeons & Dragons sheet I'm creating for me and my friends.
First a screenshot: http://prntscr.com/khmo43
What I would like is, when I input a number below 'Experience - Cell G2' (like 250), the output in cell F2 would be 1 (since a character is level 1 between 0-299 experience). However, when the experience becomes 300 or higher (between 300-900) the output should be come 2 in Cell F2.
How can I, in this case, automatically have the output in Cell F2 be determined by the value in G2. (So like, IF G2 is between A and B, F2 = C).
I'm extremely sorry if I asked a double question. I've been looking for ages.
Actually not to hard, one I had a chance to think about it. You want to use an index match with a search key as 1.
From the docs,
search_type: 1, the default, causes MATCH to assume that the range is sorted in ascending order and return the largest value less than or equal to search_key.
Because your levels are going to be sorted (I assume) you can put in the min value needed for a character to advance E.g. 0xp is the min value for level 1, 200xp is the min amount needed for level 2, 500xp is the min amount needed for level 3, etc.
=INDEX($E$2:$E$7, MATCH($A$2,$D$2:$D$7, 1))
Good luck with the campaign!
I have set of columns that I am attempting to calculate the combined total of those columns then subtract from that total 8, if the difference after 8 is equal to or less than 0 I want to only show zero in the column I am doing this formula in. For those who might ask, I am using the ARRAYFORUMLA cause I want this calculation to repeat as I add new rows, keeping the totals I am seeking on the same row as the calculation is being done onto. So far I have most of this working. Well up to the IF ELSE THEN type of portion. My attempt is/was
=if(LTE((B3:B)+(C3:C)-8,0),ARRAYFORMULA((B3:B)+(C3:C)), 0)
As long as I'm understanding you correctly, I believe this will work:
=if(lte(sum(B2:C)-8,0),0,sum(B2:C))
It's at the top of the row and sums columns B and C. You can add more columns easily this way by either changing B/C to something else or passing more columns in.
Sum-8 is greater than 0
Sum-8 is less than 0
If what you want to do is to add each row to the total but only if its sum is 8 or greater, then your original formula was nearly OK but the two parts of the IF statement should have been reversed
=sum(ArrayFormula(if(LTE((B3:B)+(C3:C)-8,0),0,(B3:B)+(C3:C))))
You could also take most of the brackets out
=sum(ArrayFormula(if(LTE(B3:B+C3:C-8,0),0,B3:B+C3:C)))
and this would also work
=sum(ArrayFormula(if(LTE(B3:B+C3:C,8),0,B3:B+C3:C)))
Short answer
ARRAYFORMULA that can show 0 if the value is less than or equal to zero. Otherwise show the value of that set of data:
=ArrayFormula(IF(LTE(A1:A3,0),0,A1:A3))
Explanation
The basic IF syntax requires the use of scalar values, to use it with arrays, ARRAYFORMULA is required as an outer function:
ARRAYFORMULA(IF(array_logical_expression,array_if_true,array_if_false))
For the specific case described on the body of the question, the corresponding formula is:
=ARRAYFORMULA(IF(LTE(B3:B+C3:C-8,0),0,B3:B+C3:C))
Reference
Google Docs editors Help
IF
ARRAYFORMULA
Using arrays in Google Sheets
Has anyone had experience of using the Excel OFFSET or INDIRECT spreadsheet functions inside a range formula?
I want to use a sum a column of values, but with a horizontal offset specific to each row, where the size of the offset is a different column. So e.g. if the data in range A1:C3 is:
[1 2 3;
1 2 3;
1 2 3]
And the offset given in D1:D3 is [0; 1; 2], I want to use some syntax like {=sum(offset(A1:A3, 0, D1:D3)} to give 6.
Another option would be to use the INDIRECT function, using syntax like {=SUM(INDIRECT("R"&ROW(A1:A3)&"C"&D1:D4,FALSE))}.
Both of these return the result as it if was just the first element of the matrix and vector, i.e. 1. Is this a restriction on these functions, or there is a way around this? Thank you.
(the answer is completely reedited after the discussion in the comments)
The OFFSET function is of no use here, as it operates with ranges and not with individual cells.
For the SUM function, everything is quite easy {=SUM(A1:C3*(COLUMN(A1:C3)=D1:D3))}. Or you might even avoid using the arrays with =SUMPRODUCT(A1:C3,(COLUMN(A1:C3)=D1:D3)). Note that column D now should refer to a specific column number and not to an offset from the first column, i.e. 1;2;3.
For other functions, it's more difficult a) because they count zeros (false values) from the matrices; b) because they usually don't work with non-contiguous arrays (and any attempt to exclude zero-values from the matrix runs into the #value error). However, the combination of FREQUENCY and INDEX does the trick:
finding average: {=(SUM(A1:C3*(COLUMN(A1:C3)=D1:D3)))/INDEX(FREQUENCY((A1:C3*(COLUMN(A1:C3)=D1:D3)),0),2)}
finding median: {=MEDIAN(LARGE((A1:C3*(COLUMN(A1:C3)=D1:D3)),ROW(INDIRECT("1:"&INDEX(FREQUENCY((A1:C3*(COLUMN(A1:C3)=D1:D3)),0),2)))))}
Hope it helps.