Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Modify your data by adding a new a new column something easily recognisable such as Waterfall
  2. Now insert a new null row. You will now use two easily identifiable markers here, any thing you like just ensure that the null line receives one mark, and the remaining fields receive the other:
    1. I tend to call the null line "start" and all remaining rows in the set as "end"

      Code Block
      titleSQL Example
      collapsetrue
      -- Using Superstore Sales as an example
      
      Select
      Segment
      ,Category
      ,Order_Date
      ,Shipping_Mode
      ,Customer_ID
      ,Sum(Sales) As Sales
      ,Sum(Profit) As Profit
      
      From orders
      
      Group By
      Select
      Segment
      ,Category
      ,Order_Date
      ,Shipping_Mode
      ,Customer_ID
      
      -- will become:
      
      Select
      Segment
      ,Category
      ,Order_Date
      ,Shipping_Mode
      ,Customer_ID
      ,Sum(Sales) As Sales
      ,Sum(Profit) As Profit
      ,'start' As Waterfall
      
      From orders
      
      Group By
      Select
      Segment
      ,Category
      ,Order_Date
      ,Shipping_Mode
      ,Customer_ID
      
      Union All
      Select
      Null As Segment
      ,Null As Category
      ,Null As Order_Date
      ,Null As Shipping_Mode
      ,Null As Customer_ID
      ,0 As Sales
      ,0 As Profit
      ,'end' As Waterfall
      
      From orders


  3. With the data prepped, its now time to load it:
  4. Once loaded, create a new calculation "waterfall_build" - and define the extra number of days as being one less than required, so if using Sales, Profit, Quantity and Forecast and then Grand Total, only define +4 rather than +5 as today will be counted as one field

    Code Block
    titlewaterfall_build
    If waterfall = 'start' Then Today() Else Today() + 4


  5. Now, drag the [waterfall] field onto the rows, and right-mouse drag the waterfall_build value beside it as discrete dates, notice that Tableau has assigned the values as expected.
  6. Now for the 'magic':
    1. Right-mouse select the waterfall_build and select Show Missing Values - nothing will happen
    2. Now, remove the [waterfall] field from the view, notice that now, Tableau has plotted five fields: the start and end date, and the missing dates in between.
  7. Switch the chart so the waterfall_build is now on the columns
  8. Next, define your headers:

    Note

    We are using table-calculations, specifically, index to tell Tableau exactly what to plot where: Using the date-plot, Tableau will treat each field as a new index value allowing us to plot the chart


    Code Block
    titleheaders
    Case Index()
    	When 1 Then 'Sales'
    	When 2 Then 'Profit'
    	When 3 Then 'Quantity'
    	When 4 Then 'Forecast'
    	When 5 Then 'Grand Total'
    End

    And then place onto your chart beside the waterfall_build field

    1. Right-mouse select the waterfall_build field and deselect Show Header so now we have successfully disguised the date fields with our own defined fields from headers
  9. Now the final set of calculations:
    1. Values to calculate the numbers:

      Note

      It is imperative to use the Total() function here, this will sum the complete value for your set and plot that one value, otherwise, Tableau will attempt to plot the value against a non-existent dimension


      Code Block
      titleValues
      Case Index()
      	When 1 Then Total(Sum(Sales))
      	When 2 Then Total(Sum(Profit))
      	When 3 Then Total(Sum(Quantity))
      	When 4 Then Total(Sum(Forecast))
      End


    2. Cumulative, used for the output of the grand-total, as the normal grand-total will not work here as the fields are superficial:

      Code Block
      titleCumulative
      Running_Sum([Values])

      we do not need to aggregate this value as the values are already aggregated in the previous calculation

    3. Treads to provide us with the drops, so these are negative as with a normal waterfall; we run the negative on the values for the measures, and a negative on the cumulative for the grand total:

      Code Block
      titleTreads
      If Index() < 5 Then -[Values] Else -[Cumulative] End


    4. Output Values - these are the actual values, so this field is nearly identical to the treads but for the removal of the sign:

      Code Block
      titleOutput_Values
      If Index() < 5 Then [Values] Else [Cumulative] End


  10. And now, we just need to put the waterfall together:
    1. From the Marks card, switch the chart type to Gantt
    2. Drag Cumulative  to the rows - As a Gantt chart, Tableau will only plot the highest point of the data
    3. Drag Treads onto the size mark to build the drop
    4. Drag Output_Values onto the labels

...