Getting rid of decimals

Answered

Comments

14 comments

  • Rainer Grabowski (FVM)

    If the calculation field is number type, you can set the decimals in the field setup menu (little arrow besides the field icon).
    With JS you can use total_amount.toFixed()

    0
    Comment actions Permalink
  • Matt Werner

    You can also change the options in the calculation field to display a whole number only. Just click on the calculator icon within your template and you will see the option there.

    -1
    Comment actions Permalink
  • Felix Blanke

    Thanks for your answers, but unfortunately none of them solved the problem. The thing is that the two number fields are ok but when they are added in the calculation field, the zeroes get added on.

    0
    Comment actions Permalink
  • Matt Werner

    Did you set your calculation field to display only whole numbers? It defaults to two decimals even if the number segment is set to only whole numbers.

    1
    Comment actions Permalink
  • Felix Blanke

    Wow, that solved it. Both thankful and embarrassed... Thank you very much Matt Werner!

    0
    Comment actions Permalink
  • Matt Werner

    No problem. Sometimes its the simplest things that we can't see when doing complicated stuff. Glad I could help!!

    0
    Comment actions Permalink
  • Lee Standell

    Hi,

    Can you explain in a bit more details where this extra option box is for calculation fields?

    All I can see is a little drop down arrow next to the calculator button with the options of required field and hidden if empty?

    Thanks

    Lee

    0
    Comment actions Permalink
  • Matt Werner

    Lee,

    The option should be there for you, I can't attach a screen shot so here is an imgur link. http://imgur.com/bnM2f9c

    Hope that helps!

    Matt

    0
    Comment actions Permalink
  • Rainer Grabowski (FVM)

    Hi Lee,

    as I've written in my first post the option to set decimals is only available in calculation fields which are number type. Your calculation field seems to be text type (cause you have a text string as result of your input). Which kind of type a calculation field is, will be defined automatically depending on what's in the calculation field when you save it clicking "done" in the template creator. The type can't be changed once it is defined.

    If you would like to have a calculation field as number type in your app you have to delete your existing calculation field and to create a new one with a code that results in a pure number. To make sure that a calculation field is number type you can only put in e.g. a relation to a number field (type: @your_number_field), then save the template, open it again and type in your wished calculation. If the result of your wished calculation code is a string you'll get an error notification - and then you have to change the code. If you need help to change your code, show it here, maybe I can give you a tip.

    Good luck.
    Rainer

    0
    Comment actions Permalink
  • Lee Standell

    Hi Rainer and sorry to highjack your thread felix.

    Thanks for clearing up the way the calculation field works, I've now set to them numeric but this has kind of lead me onto another problem.

    I'm using zapier to pull the data from podio into another web app called webmerge which will automatically create my quotations for my customers.

    Although setting the field in Podio to only 2 decimal places will show this value in 'podio'. See here http://imgur.com/tbptF0y

    When I pull the data over into Zapier it adds on the extra decimal places again See here:- http://imgur.com/7gxlLFT

    and then finally where the data is meant to end up in my quotation template it's done it again. See here:- http://imgur.com/GCuhkPs

    That's why I was thinking that maybe I need to use some kind of javascript to do the rounding in the calculation field but have no idea where to start as I can't code (yet).

    I've tried using .toFixed(2) and I think this is what mucked it up last time...

    Any ideas?

    Lee

    0
    Comment actions Permalink
  • Rainer Grabowski (FVM)

    Hi Lee,

    the setting options only define how the number is displayed in the Podio item. But the original value with 4 decimal places wouldn't be manipulated by the settings. I don't use Zapier so I don't know which format will be transferred from Podio to Zapier.
    Maybe it works with:
    Number((@Price Ex VAT)/100*5).toFixed(2)

    0
    Comment actions Permalink
  • Lee Standell

    You are the man, great stuff Rainer:)

    That works:)

    0
    Comment actions Permalink
  • Rich

    I had the same issue. Rainer Grabowski totally nailed it. Thanks!

    0
    Comment actions Permalink
  • Scott Anderson

    @Rainer  - I could use your help with a rounding issue.  I read this entire thread and your input about how the Calculation field determines if the field is a number or text field was VERY helpful and confirmed what I thought I was seeing, but was not certain.  For that - thank you!  

    ...however, the problem is that I have a rather lengthy set of calculations that take % of various other items, does a few more calculations, etc.  Needless to say when the final calculation is made, the total is off by a 1 cent!  I figure I need to round some of these numbers to get back to a pure 2 decimal placed number (not 4 places).  I have used the .toFixed(2) method.. and after much trial and error found that the field had converted to text.. which you confirmed here.. ugh!

    How can I round various fields to 2 decimal places AND STILL keep them as numbers (not text) that can be used in further calculations??  I would be most grateful for your help.  Thank you. 

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk