Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
Training
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Contact


Privacy Policy



FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

 

 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

FormatPercent ( Number ; Decimals )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 4.5  (37 votes)
  Discuss this Custom Function

Will Loving, Dedication Technologies, Inc.
http://dedicationtechnologies.com

Formats a number as a percentage text string with specified number of decimal places

Sample Input:
FormatPercent ( .4587 ; 1 )
Sample Output:
45.9%


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

Description:

Formats a number value as a percentage in a text string with the specified number of decimal places, from 0 to 10. Useful for calculated text strings that need to include a formatted percentage.

17 Jan 2011 - modified to address issue noted by Jeremiah Hammond.

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

This is my Custom Function and I want to edit it

Discuss:

The current version (as of 01/17/2011) fails with the following input: FormatPercent( .1304 ; 1 ). It'll return 1300% instead of 13.0%. The issue has to do with the ending case statement, where the rounded percent - integer of the rounded percentage happens to equal 0, instead of some decimal (say: 13.0 - 13). The function will attach zeros to the whole number portion of the percentage without a decimal.

Here's a fixed version of the function:

Case ( Decimals = 0 or IsEmpty ( Decimals ) ; Int ( Round ( Number * 100 ; 0 ) ) ;
Int ( Round( Number * 100 ; Decimals ) ) &
Case ( ( Number * 100 ) = Int ( Number * 100 ) ; Left ( ".0000000000" ; Decimals + 1 ) ;
Round ( Number * 100 ; Decimals ) - Int( Round ( Number * 100 ; Decimals ) ) = 0 ; Left ( ".0000000000" ; Decimals + 1 ) ;
Left ( Round ( Number * 100 ; Decimals ) - Int( Round ( Number * 100 ; Decimals ) ) & "0000000000" ; Decimals+1 ) ) )
& "%"

Jeremiah Hammond, Indianapolis
January 17, 2011 2:09am

It would be cool if this could be modified to accept a minimum decimal and a maximum decimal parameter, where the minimum would be used in cases where the number is an integer and max is for a non-integer. E.g. I'd prefer to display "50%" or "50.00%" rather than "50.000000%", but if the numeber is non integer I would want to see 6 decimal places, such as "3.056214%".

Tom R., Denver
May 09, 2012 7:50am

Tom - To achieve the result you are looking for, simply replace the first "Result" text - Left ( ".0000000000" ; Decimals + 1 ) - in the second Case statement (3rd line of the calculation) with empty quotes.

Will Loving, Amherst, MA
May 09, 2012 8:18am

Thanks, Will. I'll give it a try.

Tom, Denver
May 09, 2012 10:55pm

Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:

Your Name:
City/Location:
Comment:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 5 + 5 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. NumberToHexadecimal(NumberValue)
  (Fri, Dec 08, 8:54am)
2. Get_BaseTable
  (Thu, Dec 07, 4:27pm)
3. JSONCreateVarsFromKeys ( json ; namespace )
  (Wed, Dec 06, 8:21pm)
4. GetTableNzme ( field )
  (Tue, Dec 05, 9:16pm)
5. TimeFormatAsText ( theTime )
  (Mon, Nov 13, 1:59pm)
6. ParseWebValueList( text )
  (Thu, Nov 02, 9:52am)
7. SVG_HTML_to_Text ( _svg_text ; _orig_text ;
  (Wed, Oct 25, 4:17am)
8. decFromHex ( hexValue )
  (Mon, Oct 16, 12:34pm)

RSS Feed of Custom Functions