My.ADVISOR.com Sign-In
ID
Password

Member Center / Sign-Up
Go to Article
Advanced Search 

ADVISOR ANSWERS

Minimize FileMaker Pro Calculation Confusion

Learn how to use multiple functions in a single calculation while still keeping all your formulas straight.

By Lee Lukehart, Soliant Consulting director of training


Q: I've recently discovered the power we have in defining calculation fields. It knocks my socks off, what I can do with all the built-in functions, but I get easily confused when I try to use multiple functions in a single calculation. Sometimes, just to keep things straight, I resort to defining parts of the formula in two or three fields, then combining them in yet another "final result" calculation field. I know this isn't the most elegant approach, but it's the best way I've found to keep all my formulas straight. Can you recommend another approach?


Figure 1: Make a formula more readable by adding spaces and blank lines -- FileMaker Pro ignores whitespace and will interpret the calculation identically either way. So, if it helps you read the formula, go ahead and take up some space!


Figure 2: Helpful comments -- Leave yourself notes where you can best use them: in the calculation itself. FileMaker Pro supports two styles of embedded comments in calculations.

A: Welcome to the world I call "back in 7th grade algebra." I don't know about you, but many years have passed since I first learned (and subsequently forgot most of) algebra. What does this have to do with FileMaker Pro? Two things: managing parentheses and using variables. I'm going to suggest these techniques as two ways to minimize calculation confusion.


One thing I remember from algebra is that in any formula or expression, parentheses must come in balanced pairs: one left and one right. Combine a few functions in FileMaker Pro and those parentheses start getting hard to track. My first suggestion is that you give yourself some room and visually open up your formula. Make the specify calculation dialog larger by dragging the lower right corner down and use the correspondingly larger formula box to your benefit. For this tip, height is usually more important than width.

FileMaker Pro's specify calculation is blind to whitespace, meaning it ignores spaces and blanks lines. So the key is to put spaces and blank lines (using the return key) into your formula so it's more easily readable for you. For demonstration, I'll use a common calculation that returns an age in years by using the field Birthdate and some of FileMaker Pro's built-in functions. This method of determining age subtracts the current year from the birth year, and subtracts 1 if the birthday hasn't passed yet this year. In this formula you must determine whether the birthday has already occurred this year. So you have to derive this year's birthday by creating a date using the function Date(month;day;year), taking the month and day from Birthdate but obtaining the current year from the Get(CurrentDate) function. Look at figure 1 to see the improvement in legibility by laying it out in an exploded view. The formula is the same -- I've just spaced it out so the different parts are visually separated into logical sections.

Here's a bonus tip: Comment your calculation as well. FileMaker Pro lets you embed comment text in your calculation, providing two styles for you to choose from. One is known as C++ style commenting (because this is how the C++ programming language does commenting), where you start the comment with two forward slashes (//). The calculation ignores everything from // to the end of that line (designated by a carriage return). The other style is C style commenting, where you begin the comment with the characters /* and end it with */. The calculation ignores everything between and including those characters. This style is useful when your comment comprises multiple lines or when you want to insert a comment into the middle of something on one line. Figure 2 shows examples of both styles. Don't worry about taking too much space … a formula in FileMaker Pro can be up to a whopping 30,000 characters long!

Minimize Calculation Confusion

No reader comments ... yet.

    What do YOU think about this topic? Share your advice and thoughts using this form.

    Your Name

    REQUIRED : PUBLIC

    Your E-Mail

    REQUIRED : PRIVATE

    Job, Company

    OPTIONAL : PUBLIC

    City, State, Country

    OPTIONAL : PUBLIC

    Your Web Site

    OPTIONAL : PUBLIC

    Your Comment

    Please help everyone by keeping your comments on-topic, using clean language, and not defaming or making personal attacks.


    Your e-mail address is required, but it will not be displayed to the public or given to anyone. See our Privacy Policy. Comments become visible after they pass our spam filter, and spammers and abusers are permanently blocked. Please report spam or abuse.

    Lee Lukehart is director of training for Soliant Consulting, an FBA Platinum Member. Lee is a FileMaker authorized trainer, Developer Conference speaker, and FileMaker 7/8/9 Certified Developer -- and was juggling data even before he caught the FileMaker bug in 1986.

    Printer-friendly
    page layout

    Keyword Tags: FileMaker, FileMaker FileMaker Pro, FileMaker Users

    ADVISORAMA
    The short fortune teller who escaped from prison was a small medium at large.

    ARTICLE INFO

    Advisor Basics of FileMaker Pro

    Web Edition: 2008 Week 25, Doc #19427

    Print Edition: Issue #15, Page 5

    FREE ACCESS FREE ACCESS

    SUBSCRIPTION STATUS
    You are not signed-in. If you are a subscriber to this publication, sign-in above to access locked articles. To subscribe or renew go to www.AdvisorStore.com.

    Subscribe to DATABASED.ADVISOR.com

    Get it all -- every current and past ADVISOR tech/business publication, now all-in-one subscription, with new articles and a huge reference library packed with expert advice, how-to and downloads. Subscribe now to get it all.

    DataBased.Advisor.com

    Subscribe to FileMaker Advisor Magazine

    Read the advanced guide to creating custom business database solutions with FileMaker software. Subscribe now to gain access to all the archives and downloads.

    FileMaker.Advisor.com

    Subscribe to Advisor Basics of FileMaker Pro

    Learn the fundamentals of using FileMaker Pro software. Every issue gives you step-by-step instructions on creating the databases you need. Subscribe now!

    FileMaker.AdvisorBasics.com

    Showcase Your Smarts

    Submit your tips, techniques and advice and let Advisor promote your business and build your career. Show the world what you know!

    AdvisorTips.com

    Use of this or any other site, content, product or service of Advisor Media constitutes acceptance of Terms of Use.
    Portions copyright ©1983-2008 Advisor Media, Inc. All Rights Reserved.
    Reuse or reproduction of any portion or quantity of Advisor Media's copyrighted content, in any form, for any purpose, requires written permission.
    ADVISOR®, the ADVISOR logo, and other names and logos that incorporate ADVISOR are registered trademarks, trademarks or service marks of Advisor Media, Inc. in the United States and/or other countries.
    Other trademarks are used for identification, editorial or descriptive purposes and are the property of their owners.
    Hosted by Prominic.NET Website powered by
    LOTUS SOFTWARE
    lukel004-01 posted 06/16/2008 modified 01/09/2009 03:41:55 AM ztfmfu/ztfmfu
    domino-144.advisor.com my.advisor.com 01/09/2009 03:15:55 PM