I have a value in a cell that\'s in bytes. But nobody can read 728398112238. I\'d rather it say 678.37GB
To write a formula to format it relatively easy (here\'s one
I suspect a lot of the answers here are outdated, as I did not get the expected result from the given answer.
If you have value in KB that you would like to format according to the size, you can try the following.
[<1000]#" KB ";[<1000000]#0,00 " MB";0,## " GB"
952
=> 952 KB
1514
=> 1.51 MB
5122323
=> 5.12 GB
All the answers here supply values with powers of 10. Here is a format using proper SI units (multiples of 1024, i.e. Mebibytes, Gibibytes, and Tebibytes):
[>1099511627776]#.##,,,," TiB";[>1073741824]#.##,,," GiB";0.##,," MiB"
This supports MiB, GiB, and TiB showing two decimal places.
Slight change to make it work on my region, Europe (. as thousands separator, comma as decimal separator):
[<1000000]#.##0,00" KB";[<1000000000]#.##0,00.." MB";#.##0,00..." GB"
Still same issue on data conversion (1000 != 1024) but it does the job for me.
For the exact result, I'd rather calculate it, but using display format.
Assuming A1 cell has value 29773945664927.
Count the number of commas in B1 cell.
=QUOTIENT(LEN(A1)-1,3)
Divide the value by 1024^B1 in C1 cell.
=A1/1024^B1
Display unit in D1 cell.
=SWITCH(B1, 5," PB", 4," TB", 3," GB", 2," MB",1," KB",0," B")
Hide B1 cell.
screenshot