Solved

FM - Percent to Text Custom Function Off

Posted on 2014-02-06
4
347 Views
Last Modified: 2014-02-06
Below is a PercenttoText custom function that I believe I adapted from a CurrencytoText function.  However, it does not display correctly when the 100ths digit is 0 as follows.  Notice it says 7/100 instead of 70/100.  I thought I found the problem but was wrong.  See formula below.  Thanks for your help; I know this is easy for many of you, but I get lost in too much detail.

The Tenant agrees to pay an amount equal to Nine and 7/100 (9.7%) percent of the cost of snow and ice removal.



If ( FIELD = 0; "" ;

Choose ( Int ( Mod ( FIELD;10^3 ) / 100 ) ; ""; "One Hundred "; "Two
Hundred "; "Three Hundred "; "Four Hundred "; "Five Hundred "; "Six
Hundred "; "Seven Hundred "; "Eight Hundred "; "Nine Hundred " )
 
& Case ( Int ( Mod ( FIELD;10^3 ) / 100 ) > 0 and Int ( FIELD / 10 ) > 0; "and " ; "" )

&

If ( Int ( Mod ( FIELD;100 ) / 10 ) = 1 ;

Choose ( Int ( Mod ( FIELD;10 ) ) ; "Ten"; "Eleven"; "Twelve";
"Thirteen"; "Fourteen"; "Fifteen"; "Sixteen"; "Seventeen";
"Eighteen"; "Nineteen" ) ;
Choose ( Int ( Mod ( FIELD;100 ) / 10 ) ; "" ; "" ; "Twenty"; "Thirty";
"Forty"; "Fifty"; "Sixty"; "Seventy"; "Eighty"; "Ninety" ) &
      If ( Int ( Mod ( FIELD;100 ) / 10 ) > 0 ;  "-" ; "" ) &
Choose ( Int ( Mod ( FIELD;10 ) ) ; ""; "One"; "Two"; "Three"; "Four"; "Five"; "Six"; "Seven"; "Eight"; "Nine" ) )

&

If ( Mod ( FIELD; 1 ) and Int ( FIELD ) ;" and ";"" )

&

Case ( Mod ( Int ( FIELD*10 ) ; 10 ) = 1;
      Choose ( Mod ( Int ( FIELD*100 ) ; 10 ) ; "10"; "11"; "12";
      "13"; "14"; "15"; "16"; "17"; "18"; "19" ) ;
          Mod ( Int ( FIELD*10 ) ; 10 )  >  1 ;
      Choose ( Mod ( Int ( FIELD*10 ) ; 10 ) ; ""; ""; "2"; "3";
      "4"; "5"; "6"; "7"; "8"; "9" )
      &
      Choose ( Mod ( Int ( FIELD*100 ) ; 10 ) ; ""; "1"; "2"; "3";
      "4"; "5"; "6"; "7"; "8"; "9" ) ;
          Mod ( Int ( FIELD*10 ) ; 10 )  < 1 ;
      Choose ( Mod ( Int ( FIELD*10 ) ; 10 ) ; ""; ""; "2"; "3";
      "4"; "5"; "6"; "7"; "8"; "9" )
      & If ( Int ( Mod ( FIELD;100 ) / 100 ) > 0 ;  "0" ; "" ) &
      Choose ( Mod ( Int ( FIELD*100 ) ; 10 ) ; ""; "1"; "2"; "3";
      "4"; "5"; "6"; "7"; "8"; "9" ) ;

 )

&

Case ( Mod ( FIELD; 1 )  >  0; "/100 (" & FIELD & "%)" ; Mod ( FIELD; 1 ) = 0; " (" & FIELD & "%)" ; "" )
& " percent"

 )
0
Comment
Question by:rvfowler2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 25

Accepted Solution

by:
Will Loving earned 500 total points
ID: 39840015
The function isn't particularly efficient on the fraction part. I would probably take the last section that deals with the fraction with something like this:

Right( "00" & Mod( Int( Start amount *100 ) ; 100 ) ; 2 )

This tests out correctly.
Decimal-Test.fmp12
0
 
LVL 2

Author Comment

by:rvfowler2
ID: 39840193
Worked perfectly, thanks.  You're right. very inefficient.  will have to look at the rest of it because it uses the same format.
0
 
LVL 25

Expert Comment

by:Will Loving
ID: 39840246
Actually, the translation to text section is probably OK because the words are unique and not easily calculable the way numbers are. You could take out the "hundred" from each choice in the first section and add it at the end to shorten it up, but that's all I can see right now.
0
 
LVL 2

Author Comment

by:rvfowler2
ID: 39840255
Yes, I see what you mean.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Migrated music files will not play 5 68
Mac Shared Calendar invite quiestion 6 53
Apple workstations and domain 5 61
Save Excel documents to PDF and RETAIN color 16 371
Problem: You have a hosted FileMaker database and users are tired of having to use Open Remote or Open Recent to access the database. They say, "can't you just give us something to double-click on rather than have to go through those dialogs?" An…
Yesterday Apple introduced their revolutionary new iOS 5 operating system that claims to be the ultimate mobile technology interface. One of the biggest innovations of the new operating system is the introduction of the iCloud computing network. Thi…
Users will learn how to set proper sequence settings, scale images, paste attributes, add transitions, fades, and music. Open up Final Cut Pro 7 and Create a new Project: Set the Sequence Settings. a) Click File > Easy Setup > Format > Apple ProRe…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question