Ad hoc calculations

Ad hoc calculations allow you to add calculated fields to shelves in a single view without adding fields to the data pane.

Let's say you have a simple view that shows the Rent per Guest, like this:

What if you wanted to quickly highlight any renters who had paid less than $1,450? One option would be to create an ad hoc calculation. To do so, simply double-click on an empty area of the Columns, Rows, or MeasureĀ Values cards, or on the empty space of the Marks shelf, and then start typing the code for a calculation. In this example, we've double-clicked the empty space on the Marks shelf:

Here, we've entered code that will return True if the sum of Rent is less than $1,450 and False otherwise. Pressing Enter or clicking outside the text box will reveal a new ad hoc field that can be dragged and dropped anywhere within the view. Here, we've added it to the Color shelf:

The ad hoc field is only available within the view and does not show up in the data pane. You can double-click the field to edit the code.

Dragging and dropping an ad hoc field into the data pane transforms it into a regular calculated field that will be available for other views that are using that data source.