We recently added several new types of calculated fields to TrackVia, and beefed up the built-in functions you can use in those fields’ formulas. To give an illustration of the power of these new tools, I though it would be fun to give a top ten list of Cool Things You Can Do With Formulas. Drum roll, please….
10. Calculate prices and percentages. Let’s warm up with something that’s easy to do in a spreadsheet. If I want to calculate the markup on a product in my Products database, I can create a calculated percentage field whose formula is
(retail price – wholesale cost) / wholesale cost
Conversely, if I want to calculate the retail price based on a markup percentage, I can create a calculated currency field whose formula is
wholesale cost * (1 + markup)
9. Calculate dates. Suppose I use TrackVia to manage a fleet of vehicles. I record the Last Maintenance Date of each vehicle, and want to set a Next Maintenance Date that’s 90 days later. I just create a calculated date field with the formula
dateadd(last maintenance date, 90)
8. Join first name and last name. Suppose I have a First Name field and a Last Name field in my database. I’d like an automatic field called Full Name that I can use in views, merged documents, email campaigns, etc. Piece of cake – I just create a calculated short answer field whose formula uses an ampersand to join text together like this:
first name & ” ” & last name
7. Transform data. Now we’re getting fancy. Suppose I already have a Customer Name field, but it came in from my legacy system in all caps. I want to convert the capitalization to be correct, meaning all lowercase except the first letter of each word. Piece of cake. I create a calculated short answer field called Customer Name 2 whose formula is
proper(customer name)
Then I convert that calculated short answer field to a regular(non-calculated) short answer field. Then I get rid of the original field, and rename Customer Name 2 to plain old Customer Name. As my three-year-old would say, Fwalala! (He means, Voila!) My names just changed from JOHN DOE to John Doe. I can use a similar process to transform numbers, for example distances from miles to kilometers.
6. Auto-generate web and email links. Suppose I want a link to a Google map for each record in my database. (Yes, I know I can view all of my data on a map using TrackVia’s built-in map view – but I want a separate link for each record that opens in its own window.) I create a calculated URL field with the formula
“maps.google.com?q=” & Street Address & “,” & Zip
Yes, it’s that easy. I can similarly auto-generate email links for people in my company using a calculated email field with a formula (for example) of
first name & “.” & last name & “@trackvia.com”
5. Auto-select Mr. or Mrs. Cheap parlor tricks, you say? Let’s get into some actual conditional logic. Suppose my Contacts database has a drop-down called Sex with values of M and F. I can auto-generate a Title field with a formula
if(sex = “M”, “Mr.”, “Ms.”)
That just made my TrackVia-generated invoices a bit more personalized.
4. Convert state names to abbreviations. I know what you’re thinking: “I can nest those if statements to create multi-tier logic!” Yes you can. You can also use our “map” function, which does it for you in many cases. If I have a State field in my database that contains spelled-out state names, and I want to create a calculated short answer field containing the state abbreviations, I use the formula
map(State, “New York”, “NY”, “California”, “CA”, …)
3. Conditional permissions. Suppose I’ve mastered TrackVia’s permission features and I want to set up my Sales Leads database so that sales reps can only access leads assigned to them. But I want the rep, and thus the permissions, to be set automatically based on territory. I can create a calculated TrackVia user field with the formula
map(Territory, “West”, “John Doe”, “South”, “Jane Deere”, …)
2. Link to many fields. Suppose I want to link my Orders database to my Products database, but I can’t decide which one field in the Products database I should link to. Product code? Product name? Both are useful, and when I’m adding an order, I’d actually like to see the price in the select-a-product pull-down too. That’s not hard. I create a calculated short answer field that combines all three:
product code & ” – ” product name & ” ($” & price & “)”
Then I link to this calculated field from my Orders database. The choices show up like
10029 – XL Widget ($19.95)
1. Extract parent fields. Wow, now I’m a TrackVia formula Ninja. It would be nice to have that $19.95 price in my Orders record so I can use it in a Total Amount Due calculated field. It’s easy to extract from the Product field into a calculated currency field using the snip function to grab the value between the dollar sign and the closing parentheses:
snip(Product, “$”, “)” )
Whew. What a list, huh?
Full documentation of those tricks and many more is included in our Knowledge Baseand under the Help link inside TrackVia. If you’d like help setting up any of this in your own database, please give us a call!