How to calculate z-scores

Calculating Z-Values

In statistics, the z-score (or standard value) indicates how many standard deviations an observation is above or below the population mean.

To calculate the z-score, you need to know the population mean and the population standard deviation. In cases where it is not possible to measure every observation of a population, you can use a sample to estimate the standard deviation.

Create a z-score visualization to answer questions like the following:

  • What percentage of values ​​is below a certain value?

  • Which values ​​can be considered exceptional? Which results represent e.g. B. the top 5% in an IQ test?

  • What is the relative value of one distribution compared to another? For example, Michael is taller than the average man and Emily is taller than the average woman, but who is relatively taller in their own sex?

Typically, z-scores that are less than -1.96 or greater than 1.96 are considered unusual and are therefore of interest. That is, they are statistically significant and indicate outliers.

This article explains how to calculate z-scores in Tableau.

  1. Connect to the Sample - Superstore data source, which is included with Tableau Desktop.

  2. Create a calculated field to calculate average sales.

    Choose Analysis> Create Calculated Field to open the Calculation Editor. Name the calculation Average Sales, and type or paste the following in the formula area:

  3. Create another calculated field to calculate the standard deviation. Name the calculation STDEVP Sales, and type or paste the following in the formula area:

  4. Create another calculated field for calculating the z-value. Name the calculation Z-Score, and type or paste the following in the formula area:

  5. Drag the z-value from the Data area to the Columns shelf and State / Province to the Rows shelf.

    Notice that the Z-Value field on the Columns shelf has a spreadsheet icon (that is, a small triangle) on the right:

    The STDEVP Sales function is based on the WINDOW_STDEVP function, i. H. a spreadsheet function. Conversely, the Z-Value function is a spreadsheet function because its definition contains the value STDEVP Sales. You can use a calculated field that includes a spreadsheet function in a view. You can achieve the same result by manually adding a spreadsheet to a field. You can edit the field as a spreadsheet. And that's what you do next.

  6. On the Columns shelf, click the Z-Value field, then select Calculate By> State / Province.

    This will calculate the z-score per state.

  7. In the toolbar, click the Sort descending icon:

  8. Hold down the Control key and drag the Z-Value field from the Columns shelf to the Color shelf.

    Hold down the Control key and drag a field to copy the field to an additional location in the current configuration.

  9. Hold down the Control key and drag Z-Value from the Columns shelf again, this time onto the Label shelf.

You now have a distribution of the z-scores by state. California and New York both have z-values ​​that are greater than 1.96. It can therefore be concluded that California and New York have significantly higher sales than other states.