Using predefined functions

Tableau provides many predefined functions that help us manipulate data in a certain way. These functions are divided by the type of manipulation, such as functions of numeric and string data types, or aggregate operations.

Getting ready

Let's use the sample file Sample – Superstore Sales (Excel). Open a new worksheet and select Sample – Superstore Sales (Excel) as the data source.

How to do it...

Once the data is loaded on the worksheet, perform the following steps to create a new calculated field:

  1. To calculate the square root of a number, right-click on the Measures pane and select Create Calculated Field.
  2. In the Name box, enter SquareRootofSales as shown in the following screenshot:
    How to do it...
  3. In the Formula box, enter SQRT([Sales]) and hit OK.
  4. To compare the square root of sales with the original sales, create a scatter plot of Unit Price, Sales, and SquareRootofSales by Region. From the main menu, click on Analysis and uncheck Aggregate Measures.
  5. Drag-and-drop SquareRootofSales and Sales in the Columns shelf.
  6. Drag-and-drop Region and Unit Price in the Rows shelf.
  7. Change the Mark type to Circle to create a chart similar to the one in the following screenshot:
    How to do it...

How it works...

Using a predefined function, we created a field that houses the square root values of the Sales field. This newly created field can be used similarly for other existing fields, as shown in the created chart. Taking the square root of numeric values is a common data-transformation technique used to better observe the distribution of values, including outliers. You can see from the previous chart that the SquareRootOfSales values are spread more than the original sales values, which are more clustered around certain areas.

There's more...

You can learn more about data transformation objectives and techniques from the lecture slides of Regression III: Advanced Methods Workshop by William Jacoby at http://polisci.msu.edu/jacoby/icpsr/regress3/lectures/week1/4.Transformations.pdf.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset