简体   繁体   中英

Is there a way to find the largest number of decimal places in an Excel

I have a sheet in Excel which contains a lot of numbers to varying decimal places. I'm trying to create a table in MySQL to store this data as efficiently as possible, but I need to know the highest number of decimal places in each column. Is there a function which I can use to work this out?

My dataset looks something like this:

Item | Val 1 | Val 2 | Val 3
=====|=======|=======|=======
1    | x.xxx | x.xx  | xx.xx
...  | x.xx  | x.x   | xx.xxx
n    | xx.x  | x.xx  | xx.xx

For example, in the Val 1 column, the highest number of decimal places is 3. Given the sheer size of the full dataset, however, it would be difficult for me to manually go through every column and count the highest number of decimal places.

May be it can help you. It is an excel formula.

=MAX(LEN(MID(B2:B5,SEARCH(".",B2:B5)+1,LEN(B2:B5)-SEARCH(".",B2:B5))))

Press Ctrl + Shift + Enter as it is an array formula.

截图。

If you are using VBA, VB.NET or similar you can use string functions to count the chars after '.' or ','

I am not sure about the actual excel functions to use, but my way of doing it would be to replace everything up to and including the separator with nothing and then taking the strlen of the rest.

I would do that in 'counter-sheet' and make a formula that did this for every cell in the linked 'dataset-sheet'.

At the end of each column in the counter-sheet i would show the max value and at the end of that row I would show the max value across the columns.

If I were to do it in excel, that is. It would be easier with a scripting language like python if the dataset looks exactly like You describe it.

First, however, find out if you need to be that efficient in mysql - premature optimization can drain good manpower.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM