Recalculating Data Unit values

ldoodle

New Member
Joined
Mar 2, 2010
Messages
37
Hey,

Let's say I have this:

Excel Formula:
A1: 10GB
B1: =CONVERT(A1,"Gibyte","byte")

That will give me the exact byte value of 10GB. However, I want to step up to next "whole" byte; "whole" will depend on the unit in A1:

Excel Formula:
A1: 640.5
B1: =CONVERT(A1,"Gibyte","byte")

Excel Formula:
A1: 10.5GB
B1: =CONVERT(A1,"Gibyte","byte")

That will give me 800.5MB and 10.5GB in byte value, but I'd want those to be stepped up to 641GB and 11GB (possibly even 642GB and 12GB to avoid odd number) in byte notation. However it's not as simple as rounding to 1 decimal, since this one is allowable:

Excel Formula:
A1: 1.5TB
B1: =CONVERT(A1,"Tibyte","byte")

But this one isn't:

Excel Formula:
A1: 1.57TB
B1: =CONVERT(A1,"Tibyte","byte")

That should be rounded to 1.6TB in bytes.

This is for VM sizing, e.g. you'd never spec a VM RAM with decimals in (10.5GB) but you would give it 1.5TB. Out of interest I am obviously going based on 1024 (binary) instead of 1000 (decimal). Not sure whether this is the correct way or not. Some Hypervisors still require MB notation for RAM, e.g. 10240MB for 10GB.

(I'm being cleverer than shown in the CONVERT function to actually determine the source format (B, KB, MB, GB, TB, PB, EB, ZB, YB).)

Thanks
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Thanks. That seems OK for GB, but for TB it rounds to next whole number.

55.5GB becomes 56GB = good
1.5TB becomes 2TB = not good
You can use a modified version of this formula for TB
B1: = CONVERT(INT(A1*10 + 0.9)/10, "Tibyte","byte") in your formula

However, if you provide the code for your CONVERT function the "rounding" calculation could be part of that formula, or maybe there is a better solution than what I have provided.

Samples of your unconverted data would be very helpful as well.
 
Upvote 0
You can use a modified version of this formula for TB
B1: = CONVERT(INT(A1*10 + 0.9)/10, "Tibyte","byte") in your formula

However, if you provide the code for your CONVERT function the "rounding" calculation could be part of that formula, or maybe there is a better solution than what I have provided.

Samples of your unconverted data would be very helpful as well.
Here is a sample of another way to do your conversion and format of the Memory values. All of the columns would not be necessary. I include them so you could, hopefully, see how I did the conversion.

Book3
ABCD
3RAMMIN RAM BYTES10^(n*3) DIVISORCONVERTED
410102411.0 KB
5100102411.0 KB
61000102411.0 KB
72000204812.0 KB
81000010240110.2 KB
91500015360115.4 KB
101000001003521100.4 KB
112000002007041200.7 KB
129000009000961900.1 KB
135000005007361500.7 KB
141000000100044821.0 MB
152000000200089622.0 MB
168000000800051228.0 MB
179000005900096029.0 MB
181000000010000384210.0 MB
195000000050000896250.0 MB
209000000090000384290.0 MB
211000000001000007682100.0 MB
225000000005000007682500.0 MB
239000000009000007682900.0 MB
241000000000100000051231.0 GB
257000000000700000051237.0 GB
269000000000900000051239.0 GB
271000000000010000000000310.0 GB
289000000000090000000000390.0 GB
291E+111E+113100.0 GB
309E+119E+113900.0 GB
311E+121E+1241.0 TB
329E+129E+1249.0 TB
Sheet6
Cell Formulas
RangeFormula
B4:B32B4=INT((A4+1023)/1024)*1024
C4:C32C4=INT(INT(LOG10(B4))/3)
D4:D32D4=TEXT(B4/(10^(C4*3)),"0.0 ") & CHOOSE(C4,"KB","MB","GB","TB")
 
Upvote 0

Forum statistics

Threads
1,215,086
Messages
6,123,035
Members
449,092
Latest member
ikke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top