Comments on: Conditional Formula Selection in Excel
http://ask.metafilter.com/136121/Conditional-Formula-Selection-in-Excel/
Comments on Ask MetaFilter post Conditional Formula Selection in ExcelThu, 22 Oct 2009 04:54:00 -0800Thu, 22 Oct 2009 04:54:00 -0800en-ushttp://blogs.law.harvard.edu/tech/rss60Question: Conditional Formula Selection in Excel
http://ask.metafilter.com/136121/Conditional-Formula-Selection-in-Excel
How can I create an Excel worksheet which uses something like VLOOKUP (or anything which works in a similarish way) not to pull values, but formulas? <br /><br /> So, here's the situation: I'm trying to make a single billing Excel sheet where I can keep track of invoicing multiple clients. However, due to peculiarities of my industry (translation), the formula used for billing each client is different. Some round up to the nearest 100 words, some round normally to the nearest 100 (49 rounds to 0, 51 rounds to 100), some are billed X per 100 words, some are paid Y per 100 words.<br>
<br>
I can make any one of those formulas fine, independently, but I'd like to have all clients on the same page, and use some sort of formula where I'd pick the clients name, enter the number of words in the translation, and Excel would look up in a table or something to determine that, for example, the formula for Company A is ROUNDUP(A2/100,0)*100*B2 but the formula for Company B is ROUND(A2/100,0)*100*B17 or the like.<br>
<br>
Is there any way to do this without nesting IF clauses (which would become troublesome the more clients I got)?post:ask.metafilter.com,2009:site.136121Thu, 22 Oct 2009 04:21:42 -0800BugbreadExcelconditionalformulasresolvedBy: Doofus Magoo
http://ask.metafilter.com/136121/Conditional-Formula-Selection-in-Excel#1945075
See <a href='http://www.pcmag.com/article2/0,2817,2212496,00.asp'>here</a>. You'd have to use a very light bit of VBA to do this. Just add a VBA function that looks like this:<br>
<pre>Function Evalu(ByVal S As String) As String<br>
Evalu = Evaluate(S)<br>
End Function</pre>You can then use =EVALU(A1) to run the formula that's in cell A1. This could obviously be extended by doing something like =EVALU(VLOOKUP(A1,D:J,4,FALSE)), which would run the formula in the fourth column of D:J that corresponds to the value in A1.comment:ask.metafilter.com,2009:site.136121-1945075Thu, 22 Oct 2009 04:54:00 -0800Doofus MagooBy: nalyd
http://ask.metafilter.com/136121/Conditional-Formula-Selection-in-Excel#1945101
If roundup or round normal are the only options, I'd create a column for billingtype and one for wordsbilled. Billingtype could contain "up" or "normal" WordsBilled could then contain a single IF statement =if(A2="UP", round(...), rounda(...)) This would also make the process a bit more transparrent if you ever needed to know exactly why you billed a client a specific rate.<br>
<br>
You might also want to create columns for rate and for the number you round to, so your spreadsheet would look like:<br>
<br>
<basic> | BillingType | Rate Per set of words | size of set | WordsBilled | cost<br>
<br>
BillingType and WordsBilled would be the same as described above, except instead of hard coding "100" in the round functions, you would reference the value in the "Size of set" function.<br>
<br>
Cost would then become Rate * WordsBilled<br>
<br>
I think this would make the data the easiest to read and work with, and give you some extra flexibility if a formula changed, like a big client who insists on being billed by 50 or 1000 word sets. It would also make it easy to generate a detailed invoice since all the values would be accessible.</basic>comment:ask.metafilter.com,2009:site.136121-1945101Thu, 22 Oct 2009 05:53:30 -0800nalydBy: grateful
http://ask.metafilter.com/136121/Conditional-Formula-Selection-in-Excel#1945120
Another option would be to create a table that calculates the bill for each client using all possible billing methodology, then use a VLOOKUP formula to select the correct value. You'd need to create a "Billing Methodology" field, which could potentially match the offset value in the VLOOKUP formula.comment:ask.metafilter.com,2009:site.136121-1945120Thu, 22 Oct 2009 06:21:49 -0800gratefulBy: orthogonality
http://ask.metafilter.com/136121/Conditional-Formula-Selection-in-Excel#1946232
Do what grateful suggests.comment:ask.metafilter.com,2009:site.136121-1946232Thu, 22 Oct 2009 21:44:44 -0800orthogonalityBy: Bugbread
http://ask.metafilter.com/136121/Conditional-Formula-Selection-in-Excel#1946307
Thanks for all the answers.<br>
<br>
For right now, rounding up/down and the base rate are the only variables, so I was considering nalyd's solution, but in the future there might be more difficult formulas (minimum fees, discounts for high volume, etc.) which would make it really hard to adapt.<br>
<br>
Grateful's idea was another that occurred to me, but I want to have all my billing for the year on one page, so I'd have to replicate that table tens if not hundreds of times (once for each job).<br>
<br>
Doofus Magoo's suggestion absolutely nails it, though. I did a little test run, and the only problem I encountered was that it executed everything exactly as-is (i.e. if the formula said AVERAGE(B1:C1) then it would execute exactly that, even though I wanted it to be AVERAGE(B1:C1) on line 1 and AVERAGE(B2:C2) on line 2). For future reference (in case anyone ever stumbles across this with a similar question) I solved this by switching Excel from A1 referencing style to <a href="http://www.lytebyte.com/2008/04/29/what-are-a1-and-r1c1-reference-style-in-excel/">R1C1 referencing style</a> and writing my formulas like AVERAGE(R[0]C1:R[0]C2). That way the exact same formula can be applied to any row and work fine (i.e. if I use that formula on row 1, it averages A1:B1, and if I use it on row 9, it averages A9:B9).<br>
<br>
So thanks for all the help, this will make my recordkeeping much, much easier.comment:ask.metafilter.com,2009:site.136121-1946307Thu, 22 Oct 2009 22:45:31 -0800BugbreadBy: Bugbread
http://ask.metafilter.com/136121/Conditional-Formula-Selection-in-Excel#1946336
And now that I've tried implementing it with actual formulas (not just the test run), let me say that it works GREAT!<br>
<br>
Except for one little teeny tiny thing that I could totally ignore if its unfixable, but which would be great if it were fixable: the number it returns is unformattable. For example, I ran the formula on one set and got:<br>
<br>
3450<br>
<br>
That's exactly the number I wanted, but I'd like to have a currency mark and a thousands comma, like so:<br>
<br>
Y3,450<br>
<br>
That's usually dirt easy in Excel: right-click, select "Format Cells", format to your liking, and you're done. But none of the things I tested out there actually worked. I couldn't get the currency symbol to appear, nor the commas, nor to get decimal places. Any idea on how I can format it?comment:ask.metafilter.com,2009:site.136121-1946336Thu, 22 Oct 2009 23:36:16 -0800BugbreadBy: Bugbread
http://ask.metafilter.com/136121/Conditional-Formula-Selection-in-Excel#1946352
Err...nevermind, I answered my own question: TEXT(ResultOfEvaluCommand,"#,###"). Sorry, I really did research before asking my first question, but I should have done some more looking before asking that followup question.comment:ask.metafilter.com,2009:site.136121-1946352Thu, 22 Oct 2009 23:50:55 -0800Bugbread