# Tableau Prep Examples

Sometimes your data source does not contain a field (or column) that you need for your analysis. For example, your data source might contain fields with values for Sales and Profit, but not for Profit Ratio. If this is the case, you can create a calculated field for Profit Ratio using data from the Sales and Profit fields.

As a use case for generating rows in Tableau Prep, take for example this simple mock dataset – a set of invoices with start and end dates: I want to transform this into a structure that has a row for every month of a given invoice (e.g. 15 months for InvoiceNumber 1), and spread the total invoice value across the invoice billing period.

## Tableau Prep Examples Free

With Python, you can do all of this and so much more, extending the power of Tableau Prep whilst staying within the boundaries of a Tableau Prep workflow. Please note that using Python in Tableau Prep is different than using Python on Tableau Desktop. A blog on how to use Python in Tableau Desktop will be coming soon. Use Case Example. Enter an array for your input and output connections. Note: If using Tableau Prep Builder version 2018.2.2 through 2018.3.1, always include the 'inputConnections' and 'outputConnections' arrays even if the flow doesn't have remote connections for inputs or outputs.Just leave those arrays blank. If you are using Tableau Prep Builder version 2018.3.2 and later you don't need to include the blank.

This topic demonstrates how to create a simple calculated field using an example.

## Step 1: Create the calculated field

1. In a worksheet in Tableau, select Analysis > Create Calculated Field.

2. In the Calculation Editor that opens, give the calculated field a name.

In this example, the calculated field is called Profit Ratio.

## Step 2: Enter a formula

1. In the Calculation Editor, enter a formula.

This example uses the following formula:

`SUM([Profit])/SUM([Sales])`

Formulas use a combination of functions, fields, and operators. To learn more about creating formulas in Tableau, see Formatting Calculations in Tableau(Link opens in a new window) and Functions in Tableau(Link opens in a new window).

2. When finished, click OK.

The new calculated field is added to the Data pane. If the new field computes quantitative data, it is added to Measures. If it computes qualitative data, it is added to Dimensions.

You are now ready to use the calculated field in the view.