cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
We created a parameterized snippet to take a raw amount of bytes and convert it to Kilobytes, Megabytes, Gigabytes, and Terabytes accordingly. 

Snippet Name: Byte_Conversion(byte_field)
Snippet Text: 
case
  when [byte_field] > 1099511627776
    then round(1.0 *[byte_field] / 1099511627776, 2 )::decimal(6, 2) || ' TB'
  when [byte_field] > 1073741824
    then round(1.0 *[byte_field] / 1073741824, 2 )::decimal(6, 2) || ' GB'
  when [byte_field] > 1048576
    then round(1.0 *[byte_field] / 1048576, 2 )::decimal(6, 2) || ' MB'
  when [byte_field] > 1024
    then round(1.0 *[byte_field] / 1024, 2 )::decimal(6, 2) || ' KB'
  else [byte_field] || ' B'
end
Can be used in a chart like this, where the table column is num_bytes:
Select 
[byte_conversion(num_bytes)] as num_bytes
Version history
Last update:
‎03-02-2023 08:59 AM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?

Email [email protected]

Share this page: