Switch Between YoY and MoM using Parameter Selection

In previous blogs, we have discussed YoY & MoM and how and when they are used. But to have these calculations on one sheet can make the visualization more interactive as on the user’s choice it can change the selection from YoY to MoM or otherwise. The parameter is a variable that can change a constant value and helps us to make the visualization interactive.

So, here in this blog, we have to create such a visualization where we will be using a parameter for selection between YoY and MoM. It means the visualization should be switched on the basis of the selected option, if the user chooses YOY then the visualization should show the YOY calculation or otherwise

Let’s start understanding the steps with the following example: –

For Example: –Calculate YOY and MOM using the order date of the subcategories. Allow the user to choose the option between values. Use sample superstore for reference.

  • Let’s start by creating a parameter, where the data type will be a string as the value in the parameter are of string data type.

Here , in the image we are creating a parameter for selecting between YoY & MoM

  • After creating the parameter, to make it work we need to have the calculation for YOY and MOM. We also want the date should be interactive so we will create the parameter as the Order date parameter.

The calculation for YoY: –

The image shows the calculation for YoY

The calculation for MoM: –

The image shows the calculation for MoM

 In previous blogs, we have discussed the calculation of YOY & MOM.

  • We have both the calculations, but now we have to build a relationship between these calculations and parameters. So let’s create a calculated field which defined the relationship between the parameter and calculated fields.

Let’s see how the below-mentioned calculation built a relationship with the parameter

The image shows the calculation for building up a relationship between parameter and YoY & MoM calculations

Here in the calculation, it says, if the selected parameter is ‘MOM’ then the value On the sheet should be the [MoM sales] of the subcategory otherwise the value should be [YoY Sales]

Below dashboard shows the complete process that is discussed,

Here the image shows the working of added parameter on the Sub-category of the sample superstore dataset

On selection of either of the parameter, the value will be changed on the sheet itself. Hope that this blog helped the viewers to understand the  YOY or MOM selection parameter.

Check out other useful Tableau charts below:

Follow us on Twitter, Facebook, Linkedin, and Tableau Public to stay updated with our latest blog and what’s new in Tableau.