Calculating the relative share over a dimension

Here, we will learn how to create a relative share of products over the total amount of each category they belongs to.

To start, we will add the visualization, Table chart with dimension Product and Category and master measure Sales $.

Follow these steps to create the visualizations:

  1. Click on the Edit button to enter the edit mode.
  2. Click on the Charts button on the asset panel, which is on the left-hand side of the screen, and find the Table chart.
  3. Click on the Table chart, and then drag and drop it into the empty space at the bottom of the sheet:

  1. Click on the Add dimension button and select Product in the Dimensions section.
  2. Click on the Data heading in the properties panel to expand it.
  3. Find the Add column button, and then click on it and choose Dimension:

  1. Select Category in the Dimensions section.
  2. Find the Add column button, then click on it and choose Measure.
  3. Select Sales $ in the Measure section.
  4. Click on the Add column button again to add the second measure.
  5. Click on the fx button to open the expression editor, and then type the expression for the new measure, sum ( TOTAL <CategoryName> SalesAmount).
  6. Click on the Apply button to close the expression editor and save the expression.
  7. In the Label of the measure, type Category Sales.
  8. Fix the measure Number formatting to show a number with two decimal places.
  9. Click on the Add column button again to add the third measure.
  10. Click on the fx button to open the expression editor, and then type the expression for the new measure, sum (SalesAmount)/sum ( TOTAL <CategoryName> SalesAmount).
  11. Click on the Apply button to close the expression editor and save the expression.
  12. In the Label of the measure, type Category Share %.
  1. Fix the measure Number formatting to show a number as a percentage with two decimal places. The Table chart will look like this:

We learned how to calculate a more sophisticated relative share, this time over a specific group dimension. The Category dimension added to the table is referenced in the TOTAL qualifier to calculate the total amount of each category disregarding the product dimension. We can see the calculation of the share ratio of each product compared to the total amount of the category it belongs to. The share is calculated within the current selection. If we select a specific country or group of products, the share-ratio calculation changes, showing the share considering the specific selection.

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

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