How to round to the nearest 100th? (i'm not sure) - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

How to round to the nearest 100th? (i'm not sure)

Last post 06-01-2018 01:27 PM by ttrotman. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 05-30-2018 07:08 AM

    How to round to the nearest 100th? (i'm not sure)

    Hey all, I'm trying to do some math in my form that allows me to calculate money. I'm actually calculating PayPal's fees. It's 2.99% per charge, plus $.30. I do that like this: sum(MealTotal) * 2.99 / 100 + .30 So for $21.00, it calculates to 21.9279 I need that to turn into $21.90. So I tried this: round(sum(MealTotal) * 2.99 / 100 + .30 + MealTotal * 100) / 100 Which returned this: $21.01 Can anyone tell me that right code to input into the form? Thanks in advance.
    I love InfoPath
  • 05-30-2018 10:15 AM In reply to

    Re: How to round to the nearest 100th? (i'm not sure)

    Do you actually need to round this? Or can you just display as the nearest 100th in the form?
    Hilary Stoupa

  • 05-30-2018 01:51 PM In reply to

    Re: How to round to the nearest 100th? (i'm not sure)

    I just need to display it that way in the form. So I guess if there's another route I can take, I'll take it.
    I love InfoPath
  • 05-30-2018 02:04 PM In reply to

    Re: How to round to the nearest 100th? (i'm not sure)

    Wonderful! Is the data type of the field decimal? Are you displaying the data in a text box or in a calculated value?
    Hilary Stoupa

  • 05-31-2018 06:11 AM In reply to

    Re: How to round to the nearest 100th? (i'm not sure)

    I'm displaying it in a text box. The format is currency and 2 decimals.
    I love InfoPath
  • 05-31-2018 08:08 AM In reply to

    Re: How to round to the nearest 100th? (i'm not sure)

    I'm a math dunce and didn't realize that you wanted the last decimal to round, and thought the issue was just related to displaying only two decimal points! I'll see if I can figure out a way to do this later today, I'm guessing we can use substring functions....
    Hilary Stoupa

  • 05-31-2018 09:30 AM In reply to

    Re: How to round to the nearest 100th? (i'm not sure)

    Here's a sample that may help - save locally, right click & select design. You'll see in my sample, I'm not using a calculated default, but I think this approach will still work w/a calc'd default since the conditions should prevent any rule looping from resetting the field w/ the rules on it.
    Hilary Stoupa

  • 06-01-2018 10:50 AM In reply to

    Re: How to round to the nearest 100th? (i'm not sure)

    Thank you, but I think IP is doing the math incorrectly. Wouldn't 25.972 equal 25.97? Instead, the form is setting the number to 25.10. Would you happen to know how I would set up the math?
    I love InfoPath
  • 06-01-2018 11:46 AM In reply to

    Re: How to round to the nearest 100th? (i'm not sure)

    Here's what you said in your initial post: "... it calculates to 21.9279 I need that to turn into $21.90" - if all you really want is to display with two decimals, the formatting you said you have set up should already do that. I'm obviously not understanding what you are trying to do. Attaching a file with a text box w/ formatting set, just in case that's where the confusion is.... feel free to attach your form under the options tab if that might help me understand the issue.
    Hilary Stoupa

  • 06-01-2018 12:06 PM In reply to

    Re: How to round to the nearest 100th? (i'm not sure)

    Ok. I can see where I got unclear. My apologies. It's true that I want it to display with two decimals. And it's also true that what I have works to do that. What I still need is for the final price to be rounded to the nearest 100th, I believe. So when I said I needed 21.9279 to turn into 21.90, I was saying I wanted a number to round to the nearest 0 or 5. Another example would be 20.8442 turning into 20.80. I hope I didn't further confuse.
    I love InfoPath
  • 06-01-2018 12:16 PM In reply to

    Re: How to round to the nearest 100th? (i'm not sure)

    Ok - the form2 sample I posted probably does what you need in those cases, right? Except for the edge case bug where the decimal is >= .95, in which case instead of changing from 21.95 to 22.00, it changes to 21.10? Because if I enter 20.8442, I get 20.80 in that form sample. Here's a copy with the >= .95 bug fixed.
    Hilary Stoupa

  • 06-01-2018 01:27 PM In reply to

    Re: How to round to the nearest 100th? (i'm not sure)

    Perfect! Thanks Hilary. Your help is invaluable!!
    I love InfoPath
Page 1 of 1 (12 items)
Copyright © 2003-2018 Qdabra Software. All rights reserved.
View our Terms of Use.