1

Byte formatting for Google Sheets

 2 years ago
source link: https://gist.github.com/loganvolkers/933af8513ed8c2268f59c85a31761a43
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Byte formatting for Google Sheets · GitHub

Instantly share code, notes, and snippets.

Byte formatting for Google Sheets

Brilliant - thanks!

Awesome thanks!

Very cool!

Much appreciated!

This is awesome, thanks!

How would I adjust this to also accomodate for Terabyte values?

[<1000000000000]##0.00,,," GB";[<1000000000000000]##0.00,,,," TB";#,##0.00,,,,," PB"

Exactly what I was looking for @minkovich, good looking out!

This uses decimal bytes (1000 bytes = 1 KB), not binary bytes (1024 bytes = 1 KB). Is there something similar for binary bytes?

@Daniel15, I don't believe that's possible with just a custom number format. You can only cut digits off and not calculate new values. There's certainly more manual ways to format bytes correctly though. (but this is extra-nice because the formatted cells value is still treated like a number)

@varenc Yeah, that's what I thought. It's really frustrating that Sheets doesn't have it as a built in number format.

How do you use this formatting?

kaustubhcs commented on May 19, 2021

edited

Created a better one based on IF ELSE ladder.
The cell this will format is F3

=IF(F3<(1024), F3 & " B", IF(F3<(1024*1024), QUOTIENT(F3,1024) & " KB", IF(F3<(1024*1024*1024), QUOTIENT(F3,(1024*1024)) & " MB", IF(F3<(1024*1024*1024*1024), QUOTIENT(F3,(1024*1024*1024)) & " GB", IF(F3<(1024*1024*1024*1024*1024), QUOTIENT(F3,(1024*1024*1024*1024)) & " TB", "H")))))

varenc commented on Jun 20, 2021

edited

kaustubhcs that works as a formula, and is nice for using actual binary bytes, but there's advantages to using a custom number format instead of a formula! (no secondary cell, copied values are still the original byte count, etc).

Google's very sparse docs on number formats: https://developers.google.com/sheets/api/guides/formats#meta_instructions

Helped me out a lot. Thank you! :)

Is what I was looking for, thank you!

Thank you so much for this, It made my life so much easier!!

Thank you very much!

This is very useful! I can only get it to format 3 options, so if you want the MB/GB/TB version instead of the KB/MB/GB version, this looks like it works:

[<1000000000]0.00,," MB";[<1000000000000]0.00,,," GB";0.00,,,," TB"

pkowaluk commented on Apr 1

Nice work, OP. Thanks star2

Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK