Excel or Numbers, How Populate adjacent Column? - apple-numbers

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.

Related

Googlesheets contains within a Sumif and arrayformula question

I wondered if there was a way of making the following formula less memory intensive. I am currently using a SUMIF with a contains criteria to see if a substring is contained in another cell. Performing this over a large amount of data, using the wildcard approach I have opted for, is causing the sheet to become incredibly slow.
I wondered if there was a more optimal solution to the following part that I have put in bold? (Or the rest of the formula too!).
Additionally, can this be put into an array formula with the rows and columns in B:B and 1:1 the constraints?
=SUMIFS('Sheet1'!$R$2:$R,'Sheet1'!$D$2:$D,"<="&$A3,'Sheet1'!$E$2:$E,">="&$A3, 'Sheet1'!$C$2:$C, RIGHT(B$2,len(B$2)-FIND("_", B$2)), 'Sheet1'!$O$2:$O, **"*"&LEFT(B$2,FIND("_", B$2)-1)&"*"**)

How do I code Google query variables referring to text with an apostrophe in it?

Although I can find solutions to errors caused when a simple text value in a Google query contains an apostrophe, I cannot yet find a solution to when a variable in a Google query might (or might not) refer to a text value that contains an apostrophe.
I am using a simple code to extract a value (column B) related to a list of schools (column A), some of which have apostrophes in their names.
query(SchoolsData_db,"select B where A = '"&$A13&"' label B ''")
For all of the schools with apostrophes I get a #VALUE! error.
I am wondering if there is code I can run against the variable itself ('"&$A13&"') to handle the possible apostrophe. I know I can create a "cleaned name" column corollary to the school names, and then a reverse lookup to restore the names with my results table, but I am hoping the problem can be solved in each calculation instead.
You might try creating a variable first and concatenating that to the query string.
OK - interpreting the suggestion I got, I created and included a text ID column in the schools data (ex: S0001, etc.) and then I used that ID as my variable in the query. All is well. Thanks. I hope others can find this if they are similarly perplexed.

matching two columns in excel with slight difference in the spelling

I am working on huge excel sheets from different sources about the same thing. The way the sources report it and write down information is different. So, for example, one would write the location as "Khurais" whereas the other would write it as "Khorais".
Since both of these files are contain important information, I would like to combine them in one excel sheet so that I can deal with them more easily. So if you have any suggestion or tool that you think would be beneficial, please share it here.
P.s. The words in the excel sheet are translations of Arabic words.
You could use Levenshtein distance to determine if two words are "close" to each other. Based on that you could match.
You could use FuzzyLookup, a macro that allows you to do appropriate matching. It worked really well for me in the past and is actually really well documented.
You can find it here: https://www.mrexcel.com/forum/excel-questions/195635-fuzzy-matching-new-version-plus-explanation.html including examples on how to use it.
Hope that helps!
PS obviously you can also use it stricly within VBA (not using worksheet functions)
The Double Metaphone algorithm springs to mind. It attempts to convert strings into phonetic representations. For example, "Folly" and "Pholee" should have the same phonetic code.
If you could generate these codes, you could then match your records based on them, instead of the strings.
Here's an article that explains, along with sample VBA code:
https://bytes.com/topic/access/insights/965241-fuzzy-string-matching-double-metaphone-algorithm
Hope that inspires you :)

IF and conditional SUM in Google Doc Spreadsheet

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.

Find and replace from spreadsheet into spreadsheet...(Hard to sum up, sorry)

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.