I am trying to run an IF statement in Google Spreadsheet that will, if "Yes" SUM a series of values.
=IF(G3="Yes",=SUM(C3*D3)+(E3*D3))
This works (if I ignore the IF) and just do =SUM(C3*D3)+(E3*D3), so I know my math is correct.
I have read a few different posts that are asking similar questions, but many have "guesses" and are offering different structured formulas, so I'm not really even sure what the proper structure is any more.
Basically, for the nerdy portion of you, the spreadsheet does the following:
If the "killed" column is Yes, I need to calculate the XP of the monsters killed.
Base XP (C3) times Qty (D3), plus Bonus XP (E3) times Qty (D3) and them SUM the value.
The equal sign (=) in front of SUM should not be there. If your formula works I guess Google Docs just ignores it. Also, the function SUM() is useful to add the values from a range of cells from the same row or column when you don't know in advance how many cells you will add (or there are more than 2 cells and you use SUM() because it's less to write).
If I understood your request, the formula you need is:
=IF(G3="Yes",C3*D3+E3*D3)
Right now the SUM function is only wrapping C3*D3 then you are adding (E3*D3). This is the same as (C3*D3)+(E3*D3) not using the SUM function. Order of operations tells us there is no need for the parentheses so you could write C3*D3+E3*D3.
The IF function has the following parameters:
IF(EVALUATION,IF TRUE,IF FALSE)
So your final equation would be:
=IF(G3="YES",C3*D3+E3*D3,"")
I always add the FALSE return to be blank so that if I need to change it later I can do so.
Related
So I feel like this is a pretty simple question, but I cannot for the life of my find the answer, here or elsewhere.
I'm trying to autopopulate a column with custom text. I suppose it would be the row adjacent.
Thought vlookup was the solution, but I'm rusty.
Basically it's financial, if the Description contains, say, "Amazon" or "Subway" I'd like to populate the adjacent cell with "Amazon" or "Online Shopping" or "Subway" or Fast food.
I'm using numbers but assume that excel advice would apply for such a simple (seemingly) task.
Make sense?
Also, hope I formatted the image correctly.
Ok thanks!
Just looking at the sample data I can see a pattern that emerges from these transactions. However, My first thought would be to jump to VBA for Excel but I don't believe that is available for Mac OS.
Vlookup will only work with the Range_Lookup set to TRUE which means it will try to find the closest match. This might lead to incorrect matches returned or problems with the requirement for sorting your table array that is being queried.
The only other thing that came to mind which would work for a single query value such as "Amazon" OR "Subway" would be to use a nested formula that checks if that substring is found in the Description column for each cell. This would be something like:
=IF(FIND("Amazon",D1)>0,"Amazon","")
The problem with this is that it only checks for one value and it does not have an error handling mechanism so each string that is checked without the word "Amazon" in it will return a #Value error in Excel.
Hope you can help me out and inspire me here
I am looking to create a Search function that searches through a datagridview column looking for key words and then filtering based on the result. I have done this already and it works fine. However this is based on the user entering strings into the textbox separating their strings with a comma. So an example would be
A DataGridViewColumn with 3 values
ERROR_QUEUE_MAY05
ERROR_QUEUE_MAY06
ORDER_QUEUE_JAN01
The User then enters the search criteria
ORDER, 06
And the result would be
ERROR_QUEUE_MAY06
ORDER_QUEUE_JAN01
As you can see the filter has used an OR to filter the column
I want the user to be able to use brackets () and also AND statements like you would in a SQL statement so they could use for example
("ORDER" AND "MAY") OR "03"
This would filter the results to show anything with ORDER and MAY in the title or 03.
Has anyone done anything like this in the past or have any ideas of going about it?
Thanks All
One approach is to scan the string from left to right, then recursively call the evaluator every time parentheses are encountered. After a recursive call, replace the parenthesized expression with "true" or "false". If you intend to allow and a higher priority than or, you can treat that recursively as well.
I have a Google Spreadsheet and I want to run a QUERY function. But I want the WHERE statement to check a series of values. I'm basically looking for what I would use an IN statement in SQL - what the IN equivalent in Google Spreadsheets? So right now I have:
=QUERY(Sheet1!A3:AB50,"Select A,B, AB WHERE B='"& G4 &"'")
And that works. But what I really need is the equivalent of:
=QUERY(Sheet1!A3:AB50,"Select A,B, AB WHERE B='"& G4:G7 &"'")
And of course, that statement fails. How can I get the where against a range of values? These are text values, if that makes a difference.
Great trick Zolley! Here's a small improvement.
Instead of:
=CONCATENATE(G3,"|",G4,"|",G5,"|",G6,"|",G7)
we can use
=TEXTJOIN("|",1,G3:G7)
That also allows us to work with bigger arrays when adding every cell into the formula one by one just doesn't make sense.
UPD:
Going further I tried to compose two formulas together to exclude the helping cell and here we go:
=QUERY(Sheet1!A3:AB50,"Select A,B, AB WHERE B matches '^.(" & TEXTJOIN("|",1,G3:G7) & ").$'")
Used this in my own project and it worked perfectly!
Although I don't now the perfect answer for that, I could find a workaround for the problem, which can be used in small amount of data (hope that's the case here :) )
First step: You should create a "helper cell" in which you concatenate the G4:G7 cells with a "|" character:
=CONCATENATE(G3,"|",G4,"|",G5,"|",G6,"|",G7) - Let's say it's the content of the cell H2.
Now, you should change your above query as follows:
=QUERY(Sheet1!A3:AB50,"Select A,B, AB WHERE B matches '^.*(" & H2 & ").*$'")
This should do the trick. Basically we the "matches" operator allows the use of regular expressions, which also allow construction using the | symbol.
As I said, it's a workaround, it has drawbacks, but I hope it'll help.
I had the same question and came across your question in my research. Your Concatenate idea got me thinking. The problem is that the range that I'm using in my where clause is dynamic. The number of rows changes. That got me onto the Join function which lead me to this:
=(QUERY('Sheet1!A3:AB50,"select A where B = "& JOIN(" OR B = ",ARRAY_CONSTRAIN($A$5:A,COUNTIF($G$4:$G,">0"),1)) &"")
COUNTIF counts the number of rows with data. I'm using numbers in this range so maybe "!= ''" would be more appropriate than ">0". ARRAY_CONSTRAIN creates an array with with cells that only has data. JOIN turns the range into query language for the where clause.
Need to start where clause with basically same text that is in delimeter in the JOIN function. Note that I am using numbers so I don’t need ‘’ around values. This is what works in my spreadsheet and I hope it helps.
I have a table that contains details of all of our companies mobile phones. Next to this table, I need some basic stats like how many handsets of each OS there are.
Using COUNTIF I can work it all out, apart from Other. Is there a way of calculating the number of values that do not equal anything in a list of values?
This works for just 'not Android' -
=COUNTIF(Mobiles[OS], "<>Android")
But this does not work when trying to exclude all the major players -
=COUNTIF(Mobiles[OS], AND("<>Android", "<>BlackBerry", "<>iOS", "<>Windows"))
Does anybody know how I can achieve this? Thanks.
This works, it's just not very clever
=COUNTIFS(Mobile[OS],"<>Android",Mobile[OS],"<>Blackberry", Mobile[OS],"<>iOS",Mobile[OS],"<>Windows",)
Don’t count Other, instead count All and subtract Specific (as derived from COUNTIF).
I know the title isn't informative at all, but I had no idea how to sum up my question. I have 2 spreadsheets, one of them 400+ words paired with a number for each word and the other one has has the text that I will be using. So the first spreadsheet looks like this:
Column A Column B
afds 0
dshs 1
dhid 2
. .
. .
. .
dgsrs 456
And the second spreadsheet looks something like this:
Column A Column B
dhid afds
dshs dgsrs
etc. etc.
I would like to get the second spreadsheet to display the numbers that are assigned to the strings in the first spreadsheet. So I would eventually like to end up with a spreadsheet that looks like this:
Column A Column B
2 (used to be dhid) 0 (used to be afds)
1 (used to be dshs) 456 (used to be dgsrs
(The comments in brackets is just to explain, I don't want them in the final spreadsheet)
So I started doing find&replace (find a string in the second spreadsheet and replace it with the value that is assigned to it in the first spreadsheet), but I know that there must be a script for this. I am not extremely familiar with any language, but so far I have been able to run simple scripts in languages I hadn't seen before, so if you know any solution to this, please let me know, I don't care what programming language it is in, I can google a way to run it as long as it runs on mac os x (c compiler installed).
Thanks in advance!
While you could write a script to do this, the use of a translation table is common enough to be supported in many spreadsheet formula languages. In Excel-flavoured languages -- I'll use OpenOffice on the Mac, although this works with Numbers as well -- you can use the function VLOOKUP. Its calling syntax in OO looks like
VLOOKUP( valueToSearchFor ; tableToSearchIn ; columnIdentifier ; isTableSorted)
Probably easier to show it, so:
On the left hand side I put your translation table. In the centre were the cells to be translated. And on the right I wrote the formula VLOOKUP(D3; $A3:$B6; 2; 0), which translates into "look for the value of cell D3 in the translation table in the fixed region from A3-B6, use the second column as the values, and the table isn't sorted so don't try to take shortcuts while searching". Then I simply copied that cell from F3 to the F3:G4 region, to match the shape of the central data columns.
BTW, I can never remember which programs are happy with semicolons and which ones need commas, so you may need to change that.. Seaching for VLOOKUP and whatever program you use should give you all the tutorials you need. I think modern Excel even automates the process.