Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Byte formatting for Google Sheets
@kaustubhcs
Copy link

kaustubhcs commented May 19, 2021

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
Copy link

varenc commented Jun 20, 2021

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

@Smart123s
Copy link

Helped me out a lot. Thank you! :)

@eljeko
Copy link

eljeko commented Sep 14, 2021

Is what I was looking for, thank you!

@fordsho
Copy link

fordsho commented Sep 17, 2021

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

@caio-vinicius
Copy link

Thank you very much!

@alexstorer
Copy link

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
Copy link

pkowaluk commented Apr 1, 2022

Nice work, OP. Thanks 🌟

@mcsherrylabs
Copy link

Many thanks.

@OppamarkSEO
Copy link

Thank you this helped a lot.

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