Rounding Up, Down, All Around

Hi - I'm analysing an export of numbers that only provides two decimal places, which is causing errors when, for example, 26.6666666 becomes 26.67 and 30.8333333 becomes 30.83.


The resultant calculations are therefore off.


I'm hoping that someone out there will be able to guide me as to how to 'force' Numbers to recognise that these decimals should be as originally intended which would produce the correct calculation that I need.


Many thanks

Adam

Posted on Dec 14, 2023 9:45 AM

Reply
Question marked as Top-ranking reply

Posted on Dec 14, 2023 10:26 AM

I suppose you export a Numbers file to a CSV file, right? The exported values are the displayed ones and not the internal ones. So even if the internal value is 0.142856142856 but you format it to 0.14 (Number, 2 decimals), the CSV file will contain 0.14.


Therefore, what you have to do before exporting is select all the values and set their format to Automatic to display all decimals.

15 replies
Question marked as Top-ranking reply

Dec 14, 2023 10:26 AM in response to At Least 3 Character Username

I suppose you export a Numbers file to a CSV file, right? The exported values are the displayed ones and not the internal ones. So even if the internal value is 0.142856142856 but you format it to 0.14 (Number, 2 decimals), the CSV file will contain 0.14.


Therefore, what you have to do before exporting is select all the values and set their format to Automatic to display all decimals.

Dec 14, 2023 9:11 PM in response to At Least 3 Character Username

At Least 3 Character Username wrote:

Unless anyone has a better solution, I'll go with the LOOKUP table suggestion that you made.


You don't really need a lookup table. The MROUND function will do the job:



If the imported value is in A2, then:


=MROUND(A2,1/6)


MROUND - Apple Support


Fill this down an adjacent column, then remove the formulas by double-clicking that column's letter (which selects all its body cells) followed by command-c and Edit > Paste Formula Results. Then, if you want, delete the original column with the unwanted rounded values.


SG


Dec 14, 2023 11:15 AM in response to At Least 3 Character Username

Obviously, Numbers cannot guess what is the original value behind what it's receiving. Is 1.33 in fact 1.3287674, 1.33, 1.33134 or 1.333333333?


If the received values are ALWAYS sixths, 0, 1/6, 1/3, 1/2, 2/3, 5/6, you could build a small conversion table to recreate the real value. You can always adapt to other fractions as well.


Formula for the conversion, in Table2::B2 in the picture below.

=TRUNC(A2)+XLOOKUP(MOD(A2,1),Sixths::A,Sixths::B,0)


Dec 14, 2023 7:52 PM in response to At Least 3 Character Username

If all the following are true

  1. The numbers you get from the CSV are the Total column and the VAT column (not the non-taxable and taxable columns)
  2. All of the numbers in the Total, Non-Taxable, and Taxable columns will be integers. There will never be any decimals, just integers
  3. The VAT is 16.666...% (1/6) as per the numbers shown in your table, not 20% (1/5).
  4. The VAT column is column F

Then you can correct the VAT in a new column using the formula


=ROUND(F×6,0)÷6


Using that new column you can calculate the taxable amount and from there you can calculate the non-taxable amount.

Dec 14, 2023 1:14 PM in response to At Least 3 Character Username

Numbers will not be able "correct" the CSV data upon import because it has no way of knowing what the "correct" values are. In fact, Ii all of those numbers are from the CSV, they all tie together so there is no way of knowing if the problem is the non-taxable, taxable, or VAT number. They all go together. You change one and at least one of the others has to change also.


Are all the columns from the CSV or are some calculated in your spreadsheet after importing the CSV? I am assuming the data from the CSV is only the Total values and the VAT amounts and you calculated the non-taxable and taxable values. Is that correct? I'm trying to think of a way for you to correct the results but they all tie together so it isn't readily apparent how to guarantee the result of the "correction" will be correct.


Also, it looks like the VAT is not the 20% that it says in the header. It appears to be 16.666...% (i.e., 1/6).



Dec 14, 2023 11:44 AM in response to At Least 3 Character Username

Here's a screenshot. The non-taxable column shouldn't have the small errors of 0.02 in it, which is caused by the rounding error in the VAT column. (30.83 should be 30.8333333, 26.67 should be 26.666666, you get the idea...)


Unless anyone has a better solution, I'll go with the LOOKUP table suggestion that you made.


Dec 14, 2023 2:30 PM in response to At Least 3 Character Username

The VAT appears to be 1/6 of the taxable amount. It is not 20% (1/5) of the taxable amount.


Which columns of your table are from the CSV data and which are calculated by formula in your spreadsheet? If all come from the CSV then I don't see how to say with 100% certainty that the numbers in the non-taxable column (or VAT column) are incorrect. For example, how do you know for sure that 40.02 is incorrect? How do we know with 100% certainty that it is supposed to be 40.00?

Dec 15, 2023 7:56 AM in response to SGIII

That's a better formula.


I'm still wondering which columns are from the CSV file, which ones are calculated, and if the columns other than VAT are always going to be whole numbers. It falls apart if they are not. I think at least one has to be guaranteed to be whole numbers but possibly it takes two or all three.


On a different note, the forum now sort our posts. The default seems to be "best" which jumbles them all up chronologically and makes no sense. Any way to set the default to "oldest"?

Dec 15, 2023 8:08 AM in response to Badunit

Badunit wrote:

the forum now sort our posts. The default seems to be "best" which jumbles them all up chronologically and makes no sense. Any way to set the default to "oldest"?


Can also choose order here under OP.




Struggling to adapt to the new system too. Hope it's better for somebody. So far just confusion for me.


SG

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Rounding Up, Down, All Around

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.