Design

Number Formatting

List of functions to manipulate and transform your JSON numbers
COMMUNITY FEATURE Available for:
Carbone Cloud
Carbone On-premise
Embedded Carbone JS
  v2.0+ 

:formatN(precision)

v1.2.0+

Format number according to the locale.
Applying a number of decimals depends on the report type:

Params Description Type
precision Number of decimals Number

Examples

// With API options: {
//   "lang": "en-us"
// }
{d.value:formatN()} // input: "10" → output: "10.000"
{d.value:formatN()} // input: "1000.456" → output: "1,000.456"

:round(precision)

v1.2.0+

Round a number

Same as toFixed(2) but it rounds number correclty round(1.05, 1) = 1.1

Params Description Type
precision number of decimal Number

Examples

{d.value:round(2)} // input: 10.05123 → output: 10.05
{d.value:round(1)} // input: 1.05 → output: 1.1

:add(value)

v1.2.0+

Add two numbers

Params Description Type
value Value to add Number

Examples

{d.value:add(2)} // input: 1000.4 → output: 1002.4
{d.value:add('2')} // input: "1000.4" → output: 1002.4

:sub(value)

v1.2.0+

Subtract two numbers

Params Description Type
value Value to subtract Number

Examples

{d.value:sub(2)} // input: 1000.4 → output: 998.4
{d.value:sub('2')} // input: "1000.4" → output: 998.4

:mul(value)

v1.2.0+

Multiply two numbers

Params Description Type
value Value to multiply Number

Examples

{d.value:mul(2)} // input: 1000.4 → output: 2000.8
{d.value:mul('2')} // input: "1000.4" → output: 2000.8

:div(value)

v1.2.0+

Divide two numbers

Params Description Type
value Value to divide Number

Examples

{d.value:div(2)} // input: 1000.4 → output: 500.2
{d.value:div('2')} // input: "1000.4" → output: 500.2

:mod(value)

NEW v4.5.2+

Compute modulo

Params Description Type
value Y Number

Examples

{d.value:mod(2)} // input: 4 → output: 0
{d.value:mod(2)} // input: 3 → output: 1

:abs

NEW v4.12.0+

Get absolute value

Examples

{d.value:abs()} // input: -10 → output: 10
{d.value:abs()} // input: -10.54 → output: 10.54
{d.value:abs()} // input: 10.54 → output: 10.54
{d.value:abs()} // input: "-200" → output: 200

:ceil

v4.22.8+

Rounds towards closest higher integer number

Examples

{d.value:ceil()} // input: 10.05123 → output: 11
{d.value:ceil()} // input: 1.05 → output: 2
{d.value:ceil()} // input: -1.05 → output: -1

:floor

v4.22.8+

Rounds towards closest lower integer number.

Examples

{d.value:floor()} // input: 10.05123 → output: 10
{d.value:floor()} // input: 1.05 → output: 1
{d.value:floor()} // input: -1.05 → output: -2

:int

UNRECOMMENDED FOR USE v1.0.0+

Converts a number to an INT

:toEN

UNRECOMMENDED FOR USE v1.0.0+

Converts a number with English specifications (decimal separator is '.')

:toFixed

UNRECOMMENDED FOR USE v1.0.0+

Converts a number into string, keeping only decimals

:toFR

UNRECOMMENDED FOR USE v1.0.0+

Converts a number with French specifications (decimal separator is ',')

Get inspired by one of our real-life examples: Planning with subtotals, Gallery of images, Grid Layout or Bank Statement