Number Formatting
Formats are defined using the column names in your SQL query.
A format tag can be appended to your column name to ensure the right format (see table below for accepted tags).
Format tags are appended with an underscore: for example, to append the percentage format to a column named growth
, it would be growth_pct
.
Evidence will also format the column if the column’s name matches any of the accepted format tags exactly (e.g., if your column is named date
, Evidence will use the date
format).
#
Accepted TagsBelow are the currently accepted format tags and their respective formats. Most numbers are formatted with 2 decimal places. This functionality will be extended in future versions to allow for more customization of formats.
Format Type | Format Tag | Format Name | Example |
---|---|---|---|
Date | date | Date | March 17, 2021 |
Date | week | Week | March 14, 2021 |
Date | month | Month | Mar 1, 2021 |
Date | qtr | Quarter | Jan 1, 2021 |
Date | year | Year | 1994 |
String | id | ID | 355123 |
String | str | String | 355123 |
Number | pct | Percent | 12% |
Number | usd | Currency (USD) | $1,053.29 |
Number | cad | Currency (CAD) | $1,053.29 |
Number | eur | Currency (EUR) | €1,053.29 |
Number | gbp | Currency (GBP) | £1,053.29 |
Number | chf | Currency (CHF) | CHF1,053.29 |
#
Title FormattingWhen creating a table, Evidence formats column titles based on the name of the column and its format tag. Format tags that do not add to the meaning of the column name are not printed as part of the title.
#
ExamplesColumn Name | Formatted Title |
---|---|
sales_usd | Sales ($) |
customer_id | Customer ID |
growth_pct | Growth (%) |
customer_number_str | Customer Number |
#
Unit FormattingIn chart and table components, Evidence automatically formats large numbers into shortened versions based on the size of the maximum number in that column. Future versions will allow for more control over how and when units are used.
Below are the thresholds for automatic unit formats. Unit formats are applied when at least 75% of a chart axis is in those large units.
Units | Suffix | Threshold | Example |
---|---|---|---|
Thousands | k | 4,000 | 4k |
Millions | M | 4,000,000 | 4M |
Billions | B | 4,000,000,000 | 4B |
Units are combined with format tags. For example, if you had a chart with a maximum y-axis value of 10 million and your column name included the _usd
format tag, the value would be formatted as $10M