1. Subtitle: Sunburst Chart with Labels Inside and Categorical Sequential Colors

    Here I am presenting how to design Sunburst Chart with practical considerations, such as:

    • Labels inside
    • Categorical sequential colors with dynamic data.
    The design will be based on map layers, a new feature since Tableau desktop version 2020.4. This post by Sebastian Depalla is a great source of inspiration.

    First, here are two very important techniques when dealing with map layers.

    Turn off Map Background

    • This is actually the last step. After you have done all the following steps, turn off the map background: set Menu Map>Background Maps to None. Once it's off, you can't add layers.

    Size the View 

    • Use Ctrl-Shift-B/Ctrl-B to increase/decrease the size of the entire view (all layers included)
    • Use the Size card to the max

    Create Center

    • Use the formula MAKEPOINT(0,0) to create a field called Center.

    Create Subcategory Pie Layer

    Drag the field Center to the view. Change the data mark to Pie. Drag the fields to the Mark's cards exactly as in the following screenshot.
    1. Size the view with Ctrl-Shift-B as big as you can. 
    2. Place Category above Subcategory.
    3. Sort either of them by the field Sales descendingly.
    4. Place Sum(Sales) in Color. Edit Color using deep gray to create sequential color.
    5. Click Color card and set the color opacity to be ~55%

    Create Category Pie Layer

    Drag the field Center to the view and create a new layer. Change the data mark to Pie. Drag the fields to the Mark's cards exactly as in the following screenshot.
    1. Size the pie with the Size card and make it smaller than the Subcategory pie. Leave enough spaces for labels. 
    2. Place Category above Subcategory.
    3. Sort either of them by the field Sales descendingly.
    4. Place Category in Color and Subcategory in Label.
    5. Set the Label font color to white (showing labels in black for illustrative purpose only )

    Create White Circle Layer

    Drag the field Center to the view and create a new layer. Change the data mark to Pie. Drag the fields to the Mark's cards exactly as in the following screenshot.
    1. Size the pie with the Size card and make it smaller than the Category pie. Leave enough spaces for labels. 
    2. Place Category in Label.
    3. Sort Category by the field Sales descendingly.
    4. Set Color to white. (showing black border for illustrative purpose only)
    5. Set the Label font color to be white (showing labels in black for illustrative purpose only )

    Create Background Layer

    Put this layer under the Subcategory layer will generate categorical sequential colors. 

    Drag the field Center to the view. Change the data mark to Pie. Drag the fields to the Mark's cards exactly as in the following screenshot.
    1. Size the pie with the Size card to the Max. 
    2. Sort Category by the field Sales descendingly.
    3. Place Category in Color.

    Put Layers in Order

    The order of layers is as follows:
    Drag the layers to arrange them in the above order.

    Voila. It's done. You can download the demo workbook here.

    If questions, leave comment or contact me via twitter @aleksoft

    PS: Fine-Tuning the Labels (6-Layer Sunburst Chart)

    In the above workbook, we included a 6-layer Sunburst chart as well. The idea is to allow us to fine tune the position of the labels.

    By default Tableau places the labels very close to the exterior of the circle. We can manually move the labels individually to a different place. It's not good for dynamic data visualization.

    To make the position of the labels tunable and predictable, we added a transparent pie layer. For example, we can insert a Transparent Pie layer between the White layer and the Category layer, and place the Category labels on the transparent pie. By tuning the size of the latter via the Size card, we can determine the location (radius) of the labels. 

    To make a pie transparent, we only need to set a regular pie's color opacity to be 0%. Note that the transparent pie has exactly the same dimensions and measure as the one that it puts labels on. It is smaller in size (radius) and is transparent.

    In the 6-layer dashboard, we inserted two transparent pies for two sets of labels: Category and Subcategory
    You can see that the labels are placed a bit more away from the circles than the default placement by Tableau.


    0

    Add a comment

  2. [ Followup guest post by Hans Romeijn: Calculating Period-To-Date/PoP with Indicators for Better Performance ]

    Year to Date (YTD) and Year over Year (YoY) calculations are very important in business dashboards. Jim Dehner recently wrote a great post on the topic. It inspired me to present additional approaches for the issues.

    Calculating YTD and YoY without LOD

    We have been using YTD and YoY long before LOD (level of details) appeared. So we are not dependent on LOD at all. 

    Here is how we calculate YTD, YTD Sales, Previous YTDPrevious YTD Sales and YoY Change %. Note that YTD and Previous YTD can be applied to any other measure's YTD calculations.


    An example of using the above formula is provided below and here is the workbook.

    What is good about LOD?

    With LOD, such as below, it provides portability when using the same value in different sheets with different dimensions. (Caveat: make your filters contextual when using LOD). If you use it in a single sheet, LOD is not a concern. In most cases, we don't need LOD.

    Formatting YoY

    When calculating YoY change % using the native quick table calculation "Percent Difference", we find that the first column is empty. Visually it's not an agreeable thing, although we perfectly understand why. With a little formatting, we can make the viewers feel better like below. 

    Double click the green pill of Percent Difference and use ZN() to wrap around the formula. Then format the pill as follows.

    This will put a dash "-" in the empty  column. If you wish, we can put a N/A there. 

    Calculations for QTD/QoQ, MTD/MoM and WTD/WoW

    Note that you can replace the date part 'year' in YTD/YoY calculations by  'quarter', 'month' or 'week' in both DATEDIFF() and DATEADD() for calculating QTD/QoQ, MTD/MoM and WTD/WoW. Here are the calculations for QTD, Previous QTDQoQ Change % and respective sales. You can apply QTD and Previous QTD to calculating other measures.

    Calculations for QoPYQ: QTD over Previous Year QTD

    The condition for the previous year QTD is like 
    We also provide calculations for PoPYP: PTD over Previous Year PTD. P is a parameterized period which can be quarter, month or week.

    The companion workbook can be downloaded here.

    Date Grain and Anchor Date as Parameters

    PS. Tom T left a comment below saying that we can use a parameter for the date grain like year, quarter, month and week. That's very true. It will allow user to select a date grain. So here is the parameter Date Grain:

    And here is the Period to Date calculation, Period being defined by the Date Grain.

    Also Tom also suggested we can use a parameter for the anchor date instead of Today() as in Period to Date. So here is the parameter Date Select:
    And here is the PTD Select Date calculation.
    And Previous PTD, Period over Period Change % etc are included in the companion workbook. Check it out.

    Feel free to leave comments below or contact me at twitter @aleksoft .
    9

    View comments

  3. A viewer to my two button sheet swap video left a comment and asked me how to do single button sheet swap. Here is the solution.

    It takes the following steps. Assume we have two worksheets built from two data sources. But they can be built from the same data source as well. 

    Two filters with a parameter

    First let's create a parameter [Sheet Select] with 1 and 2 as list of values.

    Then for each sheet we set up a specific filter for it. For Sheet1 we have

    [Sheet Select] = 1

    For Sheet2 we have

    [Sheet Select] = 2

    Then place the filter in the filter shelf of the respective sheet and select the option True. By controlling the value of the parameter [Sheet Select], we can decide which sheet to show.

    Creating a button sheet

    Actually we duplicated the same sheet 2 more times and named the sheets for three different action types: Hover, Select, Menu. You can remove any of the sheets that you don't need.

    This button sheet has a made-up data source with a single row of value 1 in a single column "Sheet". You can create this in an Excel or CSV file and import it into Tableau.

    Then we need to create three new fields: True, False and Circular Value. And put them all the three in the Detail card. The Sheet field is a placeholder which allows an editable Label. We will put the button name in the label.

    True and False fields have content exactly as their names.

    The field Circular Value is created which will change to a value other than the current parameter [Sheet Select]. When the parameter is 1, the Circular Value is 2. Vice versa.

    The components of the dashboard

    The dashboard for sheet swap is composed of 3 button sheets and 2 chart sheets. You can always remove the buttons that you don't need.

    The two chart sheets must be placed in a vertical container. In anytime, only one sheet is visible depending on the parameter value of [Sheet Select]

    Caveat: Make sure that you hide the title of each sheet. Use area annotation for the title instead!! Otherwise, you can't hide the sheet.

    Set up a Parameter Action

    The purpose is to let the dashboard action assign a new value to the target parameter [Sheet Select]. The reference value is from that of the field Circular Value.

    Here is the Parameter action set up of the Select button.

    For the other buttons Hover and Menu, the set up is similar. Just select the corresponding Run Action On option. And select the corresponding Source Sheet.

    De-select the Select button

    For the Select button, the regular select action actually will leave the button stay selected after clicking on it. We need a Filter dashboard action to de-select the button. This technique is invented by Simon Runc and Yuri Fal. Here is the setup.

    Voila, we are done with it. The resulting demo dashboard can be found here

    Multi-sheet swapping via one button

    The same technique can be applied to multiple sheet swapping via one button. The parameter [Sheet Select] has to have a list of 1 to N numbers. For the N sheets ready to swap, each needs to have a filter like [Sheet Select] =K where K=1,..., N.

    For the Circular Value, the formula is as follows:

    [Sheet Select]%N+1

    By clicking the Select button, we can flip through all the N sheets in sequence. Same for running the other two button actions: Hover and Menu.

    2

    View comments

Blog Archive
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.