5 Replies Latest reply on Mar 27, 2013 8:42 AM by philmodjunk

    Add percent to a price

    KeithMcArdle

      Title

      Add percent to a price

      Post

           Hi Everyone

           I'm currently learning Filemaker, and I'm trying to add 2.5 percent to all product prices in the database and in the field "PartsPrices" but not sure how to do the script or if there is another way to it

           any help would be greatly appreciated

           Thanks

        • 1. Re: Add percent to a price
          JimMac

               If the PartsPrices is a permanent change, meaning that Part1234 was priced at $10 and would be NOW $10.25

               Then use the Replace function.

               1) Go to a layout that shows  the active Field PartPrices

               2)Under the Menu at top of Screen RECORDS then select Show all Records if not grey'd out.  This finds all PartPrices records to change.

               3) Click in the PartPrices field to put into "Focus" like you are ready to change it.

               4) Under the Menu at top of Screen RECORDS then select Replace Field Contents...

               You will get a Replace window... At bottom select Replace with calculated ... Click SPECIFY

               and put in this calculation...

          Round ( PartPrices * 1.25 ; 2 )   // rounds to 2 place and round up if ≥ .5

               Click OK

               Then Click Replace...

               Done with the Manual way to change all prices.

               Back up you Database first.yes

               Jim....

          • 2. Re: Add percent to a price
            Jade

                 There are many ways and it really depends on how often you need to do this.

                 The simplest way is to select the "PartsPrices" field and then choose "Replace Field Contents…" from the Records menu.  Then click "Specify" beside "Replace with calculated result:".  Enter the formula: PartsPrices * 1.025    This will add 2.5% to all PartsPrices in the found set so it is wise to make a backup of your database file beforehand.

                 If you need to do this regularly, it may be better to add a global field {number ; range 0 to 100} for the percent increase and a button with attached script to do the calculation.  The script can be as simple as: 

                 If[ not IsEmpty( your_table_name::percent_increase) ]

                    Replace Field Contents[ your_table_name::PartsPrices ; your_table_name::PartsPrices * ( 1 + percent_increase / 100 ) ]

                    Set Field[ your_table_name::percent_increase ; "" ]

                    //The percent increase field is reset to empty after the calculation to avoid doubling the increase by inadvertently double clicking the button.

                 End if

                  

            • 3. Re: Add percent to a price
              JimMac

                   Opppss correct my calculation to be...   Drinking second cup of coffeeangel

              Round ( PartPrices * 1.025 ; 2 )   // rounds to 2 place and round up if ≥ .5

              Jim...

              • 4. Re: Add percent to a price
                KeithMcArdle

                     Thanks Jim and Jade that worked, very much appreciated

                • 5. Re: Add percent to a price
                  philmodjunk

                       Some people like to keep track of past pricing and when a price change goes into effect. With a separate pricing table and an effectivity date, this can be set up fairly easily in a FileMaker Pro Database.