Skip to content

format_readable_quantity

format_readable_quantity(value)

Description

Return a human-readable string representation of a large number. Converts large integers into compact format with K, M, B suffixes (e.g. 80000008.0M, 6700067.0K).

Usage

Call or Deploy format_readable_quantity ?
Call format_readable_quantity directly

The easiest way to use bigfunctions

  • format_readable_quantity function is deployed in 39 public datasets for all of the 39 BigQuery regions.
  • It can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
  • (You need to use the dataset in the same region as your datasets otherwise you may have a function not found error)

Public BigFunctions Datasets

Region Dataset
eu bigfunctions.eu
us bigfunctions.us
europe-west1 bigfunctions.europe_west1
asia-east1 bigfunctions.asia_east1
... ...
Deploy format_readable_quantity in your project

Why deploy?

  • You may prefer to deploy format_readable_quantity in your own project to build and manage your own catalog of functions.
  • This is particularly useful if you want to create private functions (for example calling your internal APIs).
  • Get started by reading the framework page

Deployment

format_readable_quantity function can be deployed with:

pip install bigfunctions
bigfun get format_readable_quantity
bigfun deploy format_readable_quantity

Examples

1. millions

select bigfunctions.eu.format_readable_quantity(8000000)
select bigfunctions.us.format_readable_quantity(8000000)
select bigfunctions.europe_west1.format_readable_quantity(8000000)
+-------------------+
| readable_quantity |
+-------------------+
| 8.0M              |
+-------------------+

2. thousands

select bigfunctions.eu.format_readable_quantity(67000)
select bigfunctions.us.format_readable_quantity(67000)
select bigfunctions.europe_west1.format_readable_quantity(67000)
+-------------------+
| readable_quantity |
+-------------------+
| 67.0K             |
+-------------------+

3. billions

select bigfunctions.eu.format_readable_quantity(2500000000)
select bigfunctions.us.format_readable_quantity(2500000000)
select bigfunctions.europe_west1.format_readable_quantity(2500000000)
+-------------------+
| readable_quantity |
+-------------------+
| 2.5B              |
+-------------------+

4. small number (no suffix)

select bigfunctions.eu.format_readable_quantity(500.35)
select bigfunctions.us.format_readable_quantity(500.35)
select bigfunctions.europe_west1.format_readable_quantity(500.35)
+-------------------+
| readable_quantity |
+-------------------+
| 500.4             |
+-------------------+


Need help or Found a bug?
Get help using format_readable_quantity

The community can help! Engage the conversation on Slack

We also provide professional suppport.

Report a bug about format_readable_quantity

If the function does not work as expected, please

  • report a bug so that it can be improved.
  • or open the discussion with the community on Slack.

We also provide professional suppport.


Show your ❤ by adding a ⭐ on