9 Replies Latest reply on Aug 30, 2012 11:45 AM by philmodjunk

    What is the logic for assigning a decmal for a dollar?

    Kirk_1

      Title

      What is the logic for assigning a decmal for a dollar?

      Post

      Im displaying a number that i need to be in dollar form.

      The current calculation yeilds the following number... 5995619956199561995619955.6. I need it to be $599.56.

      I know i can do a left... but...

      This number will never be the same. If the numbers that yeild this number are larger the dollare amount will be 4 figures...

      EX. 13256989756326 would turn into $ 1325.69.

      In this example my calculation is (58.78 * 1700) * 60.00. 

      How do i set up the logic in script form to accomidate the varances?

       

      More info... I have to search to get my discount_pct or the 60.00 in this instance. The number of vendors that this applies to varies so i did the following set varable:

           Case ( not IsEmpty ( $discount_pct ) ; $discount_pct & "¶" ) &

      Case (
                      $shipstatecalc = "~W"  and   $constatecalc = "~W" ; Discounts::DCustPerW_W ;
                      $shipstatecalc = "~W"   and  $constatecalc = "~MW" ; Discounts::DCustPerW_MW;
                      $shipstatecalc = "~W"   and  $constatecalc = "~E" ; Discounts::DCustPerW_E;

                      $shipstatecalc = "~MW"   and   $constatecalc = "~W" ; Discounts::DCustperMW_W  ;
                      $shipstatecalc = "~MW"  and   $constatecalc = "~MW" ;Discounts::DCustperMW_MW;
                      $shipstatecalc = "~MW"   and   $constatecalc = "~E" ; Discounts::DCustperMW_E;

                      $shipstatecalc = "~E"   and  $constatecalc = "~W" ;Discounts::DCustPerE_W ;
                      $shipstatecalc = "~E"  and  $constatecalc = "~MW" ;Discounts::DCustPerE_MW;
                      $shipstatecalc = "~E"   and $constatecalc = "~E" ; Discounts::DCustPerE_E;              
                      

      )

      This finds the correct info and puts it into a portal.

       

        • 1. Re: What is the logic for assigning a decmal for a dollar?
          philmodjunk

          I don't understand what you mean by this:

          If the numbers that yeild this number are larger the dollare amount will be 4 figures...

          EX. 13256989756326 would turn into $ 1325.69.

          In this example my calculation is (58.78 * 1700) * 60.00.

          Greater than what dollar figure?

          Why wouldn't the figure be: 1325.70 (rounded to nearest penny)?

          58.78 * 1700 * 60.00 = 5995560.00

          so I don't understand where/how you get 13256989756326

          Are you saying that since 13256989756326 is greater than 5995560, you only want the left 7 digits (how is that 4 figures?) of 13256989756326 ???

          • 2. Re: What is the logic for assigning a decmal for a dollar?
            Kirk_1

            PHil can i call you?

            Or can you call me? kirkl@flgsi.com or 208-884-1710

            • 3. Re: What is the logic for assigning a decmal for a dollar?
              Kirk_1

              This is the issue:

               

              This is my calculation: ( 100 - GetValue ( $discount_pct  ; $counter ) ) * $toplinenumber / 100

               

              Where:

                    $discount_pct = 17.5

                     $toplinenumber = 1296

               

              By my calculator i should get...

                   100- 17.5 = 82.5 

                   82.5*1296 = 106920

                   106920/100 = 1069.20 whis is the number i need.

              What is there about filemaker that makes the number: 1069306930693069306930693069306930693069306930693069306930693069306930693069306  and is there a way to get the correct number?

              It can't be by just taking the numbers to the left.... its a long story...

              • 4. Re: What is the logic for assigning a decmal for a dollar?
                philmodjunk

                If $discount_pct is 17.5

                using GetValue makes no sense. What values are really in $discount_pct and $counter?

                When I use That expression, it evaluates correctly, so I think the data in one or both of these variables is not what it should be. See the screen shot.

                • 5. Re: What is the logic for assigning a decmal for a dollar?
                  Kirk_1

                  I use the getvalue because its part of  a loop. I used the loop to determine the number of vendors and what discount they offer. There could be 1 or 5... It pulls it from a sequence... 17.5, 40.3, 60.5, 50.53

                  When i use the viewer they are accurate up to the point it does my calculation above.

                  This is the loop:

                  • Exit Loop If [ Let ( [ $counter = $counter + 1 ] ; $counter > ValueCount ( $carrier ) ) ]
                  • Set Field [ Rates Dispaly::RDCarrier; GetValue ( $carrier ; $counter ) ]
                  • // Set Field [ Rates Dispaly::RDRate; Let ( [ ~min = GetValue ( $discount_min ; $counter ) ; ~pct = GetValue ( $discount_pct ; $counter ) ] ; ~pct * $toplinenumber ) ]
                  • Set Field [ Rates Dispaly::RDRate; ( 100 - GetValue ( $discount_pct ; $counter ) ) * $toplinenumber / 100 //GetValue ( $discount_pct ; $counter ) * $toplinenumber ]
                  • #provides amount to reduce toplinenumber by. When reduce it by that much i get rate before fuel.
                  • Set Field [ Rates Dispaly::RDTransit Days; GetValue ( $discount_pct ; $counter) //GetValue (100-$discount_pct ; $counter ) ]
                  • Go to Portal Row [ Select; Next; Exit after last ]
                  • #
                  • End Loop
                  • 6. Re: What is the logic for assigning a decmal for a dollar?
                    philmodjunk

                    GetValue requires that the values be separated by returns, not commas. Are they?

                    My example uses the List function to create such a return separated list so that it can demonstrate that the expression computes the correct value.

                    I think you have a comma delimitted list instead of return delimitted and thus get value is returning all the values as a single number.

                    I used the loop to determine the number of vendors and what discount they offer.

                    I've mentioned lookup tables in another thread you had. I think you need to investigate that option. Such a looping script need not be necessary

                    • 7. Re: What is the logic for assigning a decmal for a dollar?
                      Kirk_1

                      This is my script for seperating them:

                      Case ( not IsEmpty ( $discount_pct ) ; $discount_pct & "¶" ) &

                      • 8. Re: What is the logic for assigning a decmal for a dollar?
                        Kirk_1

                        I checked the viewer... the values are seperateed by a space... 17.5 40.3 60.5 50.53

                        • 9. Re: What is the logic for assigning a decmal for a dollar?
                          philmodjunk

                          Depending on how you are using the viewer, returns may show as spaces in the dataviewer. If you use the "watch" tool in the viewer and click the evaluate button, you'll get a list, but if you are just stepping through a script and the variable pops up in the viewer, the returns will show as spaces to keep the data all on one line.

                          I think you are using:

                          Case ( not IsEmpty ( $discount_pct ) ; $discount_pct & "¶" ) & DiscountValueToBeAddedHere

                          In a script to build your list of discount pct values. If so, this calculation should work as this would produce the same return separated list of values as is produced in my example with the list function.

                          If I am understanding your posts, you can actually simplify your expression to be:

                          Set Variable [$discount_pct ; value: list ( $discount_pct ; DiscountValueToBeAddedHere ) ]

                          Which doesn't explain what's going wrong with your calculation, however. I suggest putting

                          <<Discount_pct>> inside a block of text sized to be many values in height on your layout or putting it in a show custom dialog step in order to monitor the values in this variable at the time your script executes to see if there are any unexpected issues here.