Create Custom Measure Relationships in Your Tableau Data Story

You can create a relationship story in your Tableau Data Story to see how data compares to another set of data. To build a relationship story, you must have at least two measures and one dimension. Data that you'd like to compare is often grouped into one column of data named something such as "Year" or "Month," with values such as "2022" or "March."

You can Create a Simple Calculated Field to separate "2022" from "2021" (or March from February), so that you can compare the two time periods in a relationship story.

  1. Start in the sheet that you want to use in your Data Story.
  2. Click Analysis, and select Create a Calculated Field.
  3. Create a calculated field such as "Current Period."

    A calculated field that reads: If DATETRUNC (‘year’, [Year])= {MAX(DATETRUNC(‘year’, [Year]))} THEN [Number of Records] END

Tip: Follow the structure of the calculated field shown here, but substitute your own dimension or measure names (orange text).

  1. Create a calculated field such as "Previous Period."

    A calculated field that reads: If DATETRUNC (‘year’, [Year])= DATEADD(‘year’, -1, {MAX(DATETRUNC(‘year’, [Year]))}) THEN [Number of Records] END

  1. Drag the new measures onto the Detail mark.
  2. From your dashboard, click the story and add the two new measures into your Data Story.

    Data Story dialog box open to the Field tab with available dimensions and measures.

  1. From your dashboard, click the Settings icon at the top-left corner of your Data Story object.
  2. In the Data Story dialog box, click the Relationships tab.
  3. Set up a relationship story with the two custom measures.

    The Data Story settings dialog box open to the Relationships tab. The Current/Most Recent vs Previous Period box is checked. The related measures are SUM(Previous Period) and SUM(Current Period).

  1. Click Save.

Your story now writes sentences that compare the custom measures.

Thanks for your feedback!Your feedback has been successfully submitted. Thank you!