Knowledge Drop

Add a total's column to a stacked bar chart

  • 5 April 2021
  • 0 replies
  • 973 views

Userlevel 5

Last tested: Oct 14, 2020
 

Using Table Calculations, you can add a total column to a stacked bar chart. (Note: If your bar chart is not stacked, you can add a total column by simply checking the row totals box and pivoting on your dimension)

METHOD 1: TOTAL COLUMN WITH BREAKDOWN

  • Step 1: Configure your explore section so that it has one extra row than the number that you need to display. For example, in this graph we only want to display March - July, but we'll want to add 1 extra row so that we can display a total column at the end.

Screen Shot 2019-09-10 at 4.33.31 PM.png

  • Step 2: Create two table calculations. The first will create a column that displays the total of the series if it is the max row in the data set. The second will create a column that displays the word "Total" if it is the max row in the data set.

image.png

  • Step 3: Hide your original dimension and measure from the visualization so that only the table calculations and the pivoted columns remain in the visualization.

METHOD 2: TOTAL COLUMN WITHOUT BREAKDOWN (PRESERVES DRILLS)

image.png

The method used is very similar to Method 1. Step 1 is the same as we want to filter for 1 extra timeframe - above, weeks - to be able to display the total in a separate column. We should also enable totals on that Explore query.

The table calculations used are the following:

Created Week: if(row()=max(row()), "Total", to_string(${orders.created_week}))

Total: if(row()=max(row()),sum(pivot_row(${orders.count:total})), null)

Like in the previous method, hide the original timeframe dimension, and you're done! As we're still using the measure, users will still be able to drill into the chart if necessary.

This content is subject to limited support.                

 

 


0 replies

Be the first to reply!

Reply