Document toolboxDocument toolbox

Human size (humanSize)

Description

Converts a number into either binary or decimal. This is especially useful to improve readability for numbers with more than 6 digits. The result of the operation will include the KiB or KB suffix to indicate digital size.

Note that the operation name is case-sensitive and the "S" in "humanSize" must be entered in uppercase when writing LINQ queries.

Conversion to binary (IEC standard - kibibytes, mebibytes, etc.)

This conversion divides the input integer by 1024, then rounds the result to up to two decimals.

ninput / 1024 = noutput

For example, if the input value is 4000, the result will be 3.91KiB.

Conversion to decimal (Metric - kilobytes, megabytes, etc.)

This conversion divides the input integer by 1000, then rounds the result to up to two decimals. 

ninput / 1000 = noutput

For example, if the input value is 4000, the result will be 4KB.

How does it work in the search window?

Select Create column in the search window toolbar, then select the Human size operation. Only the first argument is required.

Argument

Data type

More information

Argument

Data type

More information

Original size mandatory

integer



Format 

boolean

For binary (KiB) format, leave this blank or enter True.
For decimal (KB) format, enter False.

The data type of the values in the new column is string.

Example

For the purpose of using a simple example, let's convert the values in the bytesTransferred column to an abbreviated decimal format.  We click Create column and select the Human size operation. Select bytesTransferred as the Original size argument, then add another argument. For the Format argument, we'll enter False because we want to transform the original values using a decimal conversion. Finally, we'll assign a name to the new column - let's call it BytesConverted.

Click Create column and you will see the following result:

How does it work in LINQ?

Use the operator select... as...  and add the operation syntax to create the new column. This is the syntax for the humanSize operation:

  • humanSize(integer)

  • humanSize(integer, boolean)

Examples

Copy the following LINQ script and use it to replicate the previous example. 

from demo.ecommerce.data select humanSize(bytesTransferred, false) as BytesConverted

Try this query to compare the results of binary and decimal conversion.

from demo.ecommerce.data select humanSize(bytesTransferred, false) as BytesDecimal, humanSize(bytesTransferred) as BytesBinary