Condition to show a different calculation

Here, we will learn how to create a dynamic measure in a table visualization using a condition to show the average price in the total heading and the sales amount for each category.

We will add the visualization, Table chart with dimension Category, and 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 at 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-left side of the sheet:

  1. Click on Add dimension and select Category in the Dimensions section.
  2. Click on Add Measure and select Sales $ in the Measures section.
  3. Click on the chain icon in the measure to unlink from the master measure and unlock the expression editor:

  1. Click on the fx button to open the expression editor, then type the following expression: if(rowno()=0,sum(SalesAmount)/sum(Quantity),sum(SalesAmount)).
  2. Click on the Apply button to close the expression editor and save the expression.
  3. Fix the measure Number formatting to show the number with two decimal places.
  4. Resize the width of the table to fit ten columns of the grid. The Table chart will look like this:

  1. Go to the properties panel.
  2. Click on the Appearance heading and then the General section to expand it.
  3. Switch on the Show titles property and type Sales by Category and Total Average Price.
  4. Click on the Presentation section to expand it.
  5. In the Totals labels property, type Total Average Price. The Table chart will look like this:

The sheet now looks like the following screenshot:

We learned how to create a different calculation condition for the total heading of the table. This calculation shows the average price of the products sold for the current selection.

We used the rowno() = 0 condition to test whether the line of the table is the total line. The total line is always row 0, even it is shown at the bottom of the table. The dimension values start at row 1.
..................Content has been hidden....................

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