Formatting Table Calculations

(Daniel Nelson) #1

As of version 3.22, table calculations can be formatted using value_format. Read more [here]((Formatting table calculations with value_format (3.22+)).

Formatting table calculations is not yet formally supported (as of version 3.20), but you can do quite a bit of formatting by using a combination of CONCAT and ROUND in the table calculation window. For instance, suppose you had a table calculation with values like 4.2340923 or 192.3282.

Ideally, we would want to display the table calculation as a dollar amount with two decimal places. The table calculation for the formatted column looks like

concat(“$”, round(${orders.total_amount_of_order_usd}/${orders.total_number_of_items}, 2) )

which will output $4.23 and $192.33, respectively.

A couple quick notes: Using concat will cast your field to a string, which can create some weirdness in your visualizations. I’d recommend forgoing formatting the table calcs if you’re graphing, and using the custom axis labels to indicate what your field is (dollar sign, percentage sign, etc). Also, you will not be able to format sub-cell values with this method. If you had a phone number that was represented as “xxxxxxxxxx”, you would not be able to format that into “xxx-xxx-xxxx”.


(Adam Rhuberg) #2

Is there a way to have these values graphed as numbers instead of text? It appears that using the CONCAT function, with either “$” or “%” breaks the visualization.



We’ve now added formatting via value_format to table calculations in version 3.22! This version will be released over the next couple weeks. Read more about how to use this feature here.