Number Formatting

Published on October 30, 2015

In Arcadia Instant, you can format numbers and values to customize how they are displayed. As an example, you may wish to format a value to round off a number, or to add a comma to separate thousands in a currency value and add a $ (US dollar) sign.

In this post, I’ll show you how you can change the display format of numbers in Arcadia Instant along with a couple of examples.

The following steps demonstrate how to edit the display format in Arcadia.

1.       When creating or editing a visual, determine for which Dimension or Measure you must adjust display format.
We are using sum(population), on a Measure shelf, in a visual built from State Census dataset.
2.       Click the down arrow icon to the right of the variable.

rtaimage

3.       In the dropdown, click Display Format.

rtaimage01

4.       In the Enter Display modal window, write the expression to edit display format.

rtaimage02

5.       Click Save.
6.       Click Refresh Visual.

Display Formats
Arcadia supports most of the common display formats. The high level syntax when using number formatting is:

[[fill]align][sign][symbol][0][width][,][.precision][type]

The format style for each function is signified below:

Format StyleValuesDescriptionExamples
(Input: 5679.00)
FillAll charactersAccepts all characters except curly brackets ‘{‘ ‘}’“*<6” => “5679**”
“*>6” => “**5679”
“*^6” => “*5679*”
Align<Forces left-alignment within the specified space
>Forces right-alignment within the specified space (default)
^Forces central alignment within the specified space
SignPlus +Uses a sign for both positive and negative numbers“+” => “+5679”
SpaceUses a leading space on positive numbers, and a minus sign on negative numbers” ” => ” 5679″
Symbol$Prefixes a currency symbol“$” => “$5679”
00Enables zero-padding“06” => “005679”
“6” => ”  5679″
WidthwidthDefines the minimum field width (If not specified, the width is determined by the content)
,,Enables the use of a comma to separate every 3rd digit“,” => “5,679”
Precision.precisionIndicates how many digits to be displayed after the decimal point for a value formatted with types “e”, “f” and “%”, or before and after the decimal point for a value formatted with types “g”, “r” and “p”(see f, g, r, p, and % types for examples)
TypesbBinary: Outputs the number in base 2“b” => “1011000101111”
cCharacter: Converts the integer to the corresponding Unicode character before printing“c” => “ᘯ”
dInteger: Outputs the number in base 10. Ignore non-integer values“d” => “5679”
eExponent notation: Prints the number in scientific notation using the letter ‘e’ to indicate the exponent“e” => “5.679e+3”
“.1e” => “5.7e+3”
fFixed point: Displays the number as a floating-point number“f” => “5679”
“.1f” => “5679.0”
gGeneral: For a given precision p >= 1, this rounds the number to ‘p’ significant digits and then formats the result in either fixed-point format or in scientific notation, depending on its magnitude“g” => “5679”
“.2g” => “5.7e+3”
“.5g” => “5679.0”
nFormatted Number: This is the same as’d’, except that it uses the current locale setting to insert the appropriate number separator characters.“n” => “5,679”
“.2n” => “5.7e+3”
“.5n” => “5,679.0”
oOctal: Outputs the number in base 8“o” => “13057”
rRounded: Similar to general format but does not use scientific notation“r” => “5679”
“.2r” => “5700”
“.5r” => “5679.0”
sString: Rounded and using scientific notation, but with a unit suffixed
It would render micro (0.000001 or 10-6) as 1.00μ, and it would render tera (1,000,000,000,000 or 1012) as 1.00T.
“s” => “5.679k”
“.2s” => “5.7k”
“.5s” => “5.6790k”
xHex: Outputs the number in base 16, using the lower- case letters for the digits above 9“x” => “162f”
XHex: Outputs the number in base 16, using the lower- case letters for the digits above 9“X” => “162F”
%Percentage: Multiplies the number by 100 and displays in fixed ‘f’ format, followed by a percent sign“%” => “567900%”
“.1%” => “567900.0%”

Detailed Example
We are working with the dataset Total Capital Expenditures for Companies with Employees by Industry Sector [Data source].
To visualize the Data better, we have used cross tabulation, placing the Industry on the X shelf, Year on the Y shelf and Total Expenditure on the Measure shelf.

Here’s how the raw data looks:

rtaimage03

1.The input of .2e in the Enter Display Format window shows exponential format with 2 digits after decimal.

rtaimage04

2.The input of .1f in the Enter Display Format window displays a format with 1 digits after the decimal.

rtaimage05

3.The input of 05 in the Enter Display Format window displays a 5 digit number with zero padding.

rtaimage06

4.The input of $.2fs in the Enter Display Format window displays a format with a $ sign and Roman numerals with 2 digits after the decimal.

rtaimage07

5.The input of *^9 in the Enter Display Format window displays a 9-character format that is centrally aligned.

rtaimage08