Place Bar Chart Labels Above Bars in Tableau

In this video I will provide a method in which you can place your bar chart labels above the bars in Tableau. This technique is based off Adolfo Hernandez’s technique with a little more explanation and additional alternatives for the zero line. Make sure to add this to your bar chart repertoire!

If you want to follow-along with the video, you can download the data at this link:

https://www.basketball-reference.com/leagues/NBA_2021.html

In the video I exported data from the “Per Game Stats” section but you are free to download from whichever stats section you’d prefer.

High Level Steps:

Make sure to watch the video to get more in-depth:

  1. Drag your measure to columns (e.g., 3P)
  2. Drag your dimension to Rows (e.g., Team)
  3. Sort the measure to descending value
  4. Place the Team and 3P on the label and format accordingly
  5. Create a placeholder directly on the Columns shelf : AVG(0))
  6. Drag the placeholder to the bottom of the visual onto the 3P axis to make a combined axis visual
  7. In the Measure Value area make sure that AGG(AVG(0)) is placed above SUM(3P)
  8. Uncheck “Show Headers” for the Team dimension and for the axis at the bottom of the visual
  9. Format the visual to remove unnecessary borders and lines
  10. Make the following adjustments on the Label:
    1. Marks to Label: Min/Max
    2. Scope: Pane
    3. Field: Measure Values
    4. Options:
      1. Allow Labels to Overlap Other Mark
      2. Label Minimum Value
  11. Change the color of the bar chart borders to the background color of your visual in order to camouflage the tiny bar created by AVG(0)
  12. Uncheck “Show Header” for AVG(0)

When it’s all said and done you have a fresh new take on adding labels to your bar chart that can add differentiation to your overall visual!

For more detail on how to add a zero line (which I believe is important for bar charts in general and is a good design practice), watch the video.

Please like and subscribe on the Anthony B. Smoak YouTube channel.

All views and opinions are solely my own and do not necessarily reflect those my employer

Do Great Things with Your Data!

Assign Color to Non-Existing Values in Tableau

The Issue:

I recently ran into the issue of not being able to color a dimensional value because my data did not yet contain that specific value. What I learned through trial and error is that I needed to change the calculated field I was using to force an expected value so I could color it appropriately.

I then had to change my calculated field back to what it was originally and hope that Tableau would remember the color. It would be nice if Tableau had a native built in interface to allow users to assign colors to expected values (regardless if the values are currently in the data), but this feature is not available in Tableau (looking at you very talented developers at Tableau).

Watch the Solution:

I created a calculated field with expected outcomes of “Bad”, “Normal” and “Great” based upon numerical profit data. The profit data I had did not support the “Great” value. Thus I had to doctor my calculated field to force the value and then color it. I didn’t know if Tableau would remember my color selection if I changed the calculated field and then changed it back, but it did.

The Forums:

Don’t worry, you are not the only one looking for a solution to this issue. Here are some Tableau forum links that basically ask the same questions.

Hopefully this post helped you in your search to color those non-existing values. For many of us, not all potential values are available in our data sources, and we many not have access to the underlying source data. Having a nice UI means to assign expected values in advance would be extremely useful.

The Dashboard:

I certainly love to develop new dashboards to test out functionality. I built this one to test out a few Ryan Sleeper dashboard tips. Make sure to download the dashboard .twbx file from from my Tableau Public profile (Anthony B Smoak) for free!

Please like and subscribe on the Anthony B. Smoak YouTube channel.

All views and opinions are solely my own and do not necessarily reflect those my employer

Do Great Things with Your Data!



Address Matching in Excel Using Levenshtein Distance

For my Data Analysts, in this video I will demonstrate how to perform a column comparison between two address fields so you don’t have to manually review every row. We’ll use a VBA function from Stack Overflow to provide the comparison results.

I should point out that Excel is NOT the preferred method for address matching, but sometimes it is your only option due to lack of time or better tools. Ideally, you should use address correction software that “fixes spelling errors, corrects abbreviations, and standardizes capitalization so each address in your list complies with the USPS official format” – (per the USPS). Once your addresses are standardized, THEN you should perform a comparison, but this rarely happens.

What typically happens is that some poor analyst like you is conscripted into performing address matching manually using some combination of SQL Server and manual Excel processes. That’s why a Google search led you to this page!

If you ever have to perform address matching in Excel, this could be you!

Informally, the Levenshtein distance between two words is the minimum number of single-character edits (insertions, deletions or substitutions) required to change one word into the other.

For example:

  • The string “HAT” as compared to “hat” would have a Levenshtein Distance of 3
    • Since the function is case sensitive all three characters are different
  • The string “HAT” as compared to “BAT” would have a Levenshtein Distance of 1
    • To turn the first string into the second string it would take 1 substitution of characters (H changed to B or vice-versa)
  • The lower the number, the more the strings are similar
  • The higher the number, the more the strings are dissimilar.

Activate the Developer Tab in Excel

The Developer tab is the place to go when you want to do or use the following:

  • Write macros
  • Run macros that you previously recorded
  • Create VBA Modules and User Defined Functions <– This is our sweet spot
  1. On the File tab, go to Options > Customize Ribbon
  2. Under Customize the Ribbon and under Main Tabs, select the Developer check box

Create a Module in Excel

  1. On the Developer tab select Visual Basic
  2. In the VBA interface select Insert > Module

Insert Levenshtein Distance Function VBA Code

  1. Go to this link at Stack Overflow to view the code as originally referenced
  2. Or, simply copy the code below as developed by user “smirkingman” which is the first answer.
    • Big shoutout to “smirkingman” for this great resource!
Option Explicit
Public Function Levenshtein(s1 As String, s2 As String)

Dim i As Integer
Dim j As Integer
Dim l1 As Integer
Dim l2 As Integer
Dim d() As Integer
Dim min1 As Integer
Dim min2 As Integer

l1 = Len(s1)
l2 = Len(s2)
ReDim d(l1, l2)
For i = 0 To l1
    d(i, 0) = i
Next
For j = 0 To l2
    d(0, j) = j
Next
For i = 1 To l1
    For j = 1 To l2
        If Mid(s1, i, 1) = Mid(s2, j, 1) Then
            d(i, j) = d(i - 1, j - 1)
        Else
            min1 = d(i - 1, j) + 1
            min2 = d(i, j - 1) + 1
            If min2 < min1 Then
                min1 = min2
            End If
            min2 = d(i - 1, j - 1) + 1
            If min2 < min1 Then
                min1 = min2
            End If
            d(i, j) = min1
        End If
    Next
Next
Levenshtein = d(l1, l2)
End Function
  1. Paste the code into your newly created Excel module
  2. Debug > Compile VBAProject

You should not experience any errors after compiling the code.

Watch the Video to Use the Function

Using this function in a judicious manner can help you cut down on the mental energy required to manually review the address columns on each row. It is much better to mentally focus on 25% of the rows than 100%. The fewer rows you have to manually review in Excel, the less the chance of you making an error.


Please like and subscribe on the Anthony B. Smoak YouTube channel.

All views and opinions are solely my own and do not necessarily reflect those my employer

Do Great Things with Your Data!



★☆★ Support this Channel: ★☆★

Merch ► shop.spreadshirt.com/AnthonySmoak

★☆★ FOLLOW ME BELOW: ★☆★

This image has an empty alt attribute; its file name is anthony-smoak-twitter.jpg

Twitter ► https://twitter.com/AnthonySmoak

Facebook ► https://www.facebook.com/AnthonyBSmoak/

Tableau Public ►Search for “Anthony B. Smoak”

Photo by Oladimeji Ajegbile from Pexels

Amazing Tableau Dashboard for Inspiration

I worked hard to create a Tableau dashboard packed with multiple features that any beginner or intermediate user should know how to complete. Use this dashboard as an inspiration regarding techniques to learn for your next Tableau dashboard.

Here are a few of the features included in this dashboard:

  • Parameters
  • Dynamic Titles
  • KPIs
  • Filters
  • Context Filters
  • Top 5 by Dimension
  • Highlight Actions
  • Filter Actions
  • Ranking
  • Show/Hide Containers
  • Image Buttons
  • Parameter Driven Chart Swap
  • Maps
  • Shape Files
  • Reset All Filters
  • Combo Chart / Dual Axis Chart (Bar in Bar)
  • Quick Table Calculations
  • Bullet Chart
  • Animations
  • Containerized Dashboard Layout

Because I love to teach in my relatively spare time, I am considering offering 1 on 1 training to learn how to put together this sample dashboard. As I mention in the video, leave a comment with your thoughts on how much of an investment you think someone would make for 3 hours of 1 on 1 training to build this together. Someone would definitely impress their manager or future hiring manager if they had the knowledge to build this type of front end reporting.

Let’s learn together, contact me here for more information: https://anthonysmoak.com/contact/

Interact with dashboard here ► https://tabsoft.co/3nU4c4Y


Please like and subscribe on the Anthony B. Smoak YouTube channel.

Definitely pick up some merch if you’ve enjoyed this blog and YouTube channel over the years:

https://shop.spreadshirt.com/AnthonySmoak/

All views and opinions are solely my own and do not necessarily reflect those my employer

Do Great Things with Your Data!

Anthony B. Smoak, CBIP

How to Import a BAK File into SQL Server

If you’ve ever asked “How do I import a .BAK file into SQL Server” or “What is a BAK file and how do I open it” then this is your video. Additionally, I also demonstrate how to create a .BAK file to backup your database. If you work with data then you need to know this tip!

Do Great Things with Your Data

Anthony B. Smoak

Please like and subscribe on the Anthony B. Smoak YouTube channel!
Definitely pick up some merch if you’ve enjoyed this blog and YouTube channel over the years.

All views and opinions are solely my own and do not necessarily reflect those my employer.

Tableau Dashboard Project #VIZNESSFIRST

In this video I kickstart the #VizznessFirst​ initiative where I describe a Tableau Dashboard I constructed using multiple resources from the Tableau #datafam​ community. Invest your valuable time in watching the videos as it will be worth the investment if you’re looking to pick up some new skills.

I describe the dashboard, show you the resources and then you attempt to build it. This is a perfect intermediate/advanced dashboard idea starter for students looking to improve their Tableau skills.

Background

Let’s start with a little background on how this initiative came together. I am a big fan of the Real World Fake Data (i.e., RWFD) project run by Mark Bradbourne at Tableau. I wanted to finally get involved and put together a dashboard and hopefully learn something new.

Because the particular data set used (Week 5: Help Desk) had very few measures to sum or aggregate; this left counting rows as the most informative means to squeeze some meaning from the data.

I stumbled upon an excellent blog post from Tableau Zen Master Lindsay Betzendahl where she explained a technique to highlight when a “filter” has been activated with a small indicator. I reversed engineered her dashboard to try and tease out how to pull this off with the RWFD data set.

In addition to this technique, I mashed up some other techniques from various members of the Tableau community. One of the great things that I enjoy about the Tableau community is that there are many creators who put out great content for others to learn from; whether it be videos, blog posts, PowerPoint slides, etc.

Once I had a dashboard I was proud of sharing. I figured I would release it as a series to try and teach others some of these techniques. The 3 videos in this series is the culmination of that effort.

VIDEO 1: Overview of the Project and Resources Required

Here are the references I used to put together the dashboard.

VIDEO 2: STEP BY STEP INSTRUCTIONS

Make sure to watch Video 2 above because this is where I explain the main technique required to complete the dashboard.

VIDEO 3: STEP BY STEP INSTRUCTIONS (TABLE TRICKS)

Video three rounds out the series by demonstrating a cool trick that enables you to build a filter button that opens a detailed table dashboard populated with only the records of interest from the first page. Yes, it uses a filter action but there is twist. Make sure to check it out.

SHARE WHAT YOU CREATE

  • POST YOUR FINISHED DASHBOARD TO TABLEAU PUBLIC:
    • DASHBOARD BUILT USING TABLEAU DESKTOP 2020.4.1
  • SHARE YOUR LINK IN THE COMMENTS ON THE YOUTUBE CHANNEL:
    • 10K+ SUBSCRIBERS CAN VIEW YOUR ACCOMPLISHMENT
  • YOU CAN ALSO POST TO:
    • TWITTER
    • LINKEDIN
  • MAKE SURE TO INCLUDE:


If you enjoyed this tip, please like and subscribe on the Anthony B. Smoak YouTube channel.

Definitely pick up some merch if you’ve enjoyed this blog and YouTube channel over the years:

https://shop.spreadshirt.com/AnthonySmoak/

All views and opinions are solely my own and do not necessarily reflect those my employer

Do Great Things with Your Data!

Anthony B. Smoak, CBIP

Show and Hide Containers in Tableau

In this video I’ll show you how to show and hide containers in Tableau at the push of a button. This makes for a convenient way to increase space for your dashboard while hiding your filters or switching to an additional hidden chart until needed.

If you’re not using at least Tableau 2019.2.0, then you need to run over to your I.T. department and have them set you up. In previous versions of Tableau you could achieve this effect, but you would have to implement a hacky methodology in order to pull it off. Although I love a good hack, we should all strive to work smarter not harder.

The key to pulling off the show/hide container is to add a floating horizontal or floating vertical container to your dashboard. Only once you’ve taken this step can you see the option to “Add Show/Hide Button”.

Once you’ve selected this option, any new sheets, filters or other objects you wish to place in your container are enabled to appear or disappear at the press of a button.

An “X” marks the spot as this default customizable icon will appear. You can replace this image with text or use your own customizable image in its place.

As a reminder, (from the Tableau Knowledge Base) these options “will not be available if the sheet is not on a horizontal or vertical container and that container is not floating.”

In lieu of the default show/hide icons, in the video we will use buttons from a template provided by Kevin Flerlage. Do yourself a favor and head on over to the Flerlage Twins blog and download this handy resource.

Make sure to give your filters and charts the “Personal Space” they need! Rick and Morty aficionados know exactly what I’m talking about.

For the Power BI curious, here is how a similar process is conducted, where the filters (ahem) slicers are hidden at the touch of a button.


If you enjoyed this tip, please like and subscribe on the Anthony B. Smoak YouTube channel.

All views and opinions are solely my own and do not necessarily reflect those my employer

Do Great Things with Your Data!

Anthony B. Smoak, CBIP

In all seriousness, the world lost an icon of baseball and civil rights as of the recording of this video; Mr. Hank Aaron. I live in Atlanta so I have to pay my respects with a shout out to Hammering Hank. Rest in Peace #44.

Add Total Values for Stacked Column and Stacked Bar Charts in Excel

This is the only video you need to learn how to add add totals to stacked bar charts and stacked column charts in Excel. Make sure to watch the video because I have you covered both ways.

I’m more of a video explanation person, so make sure to watch the video so the steps are clearer. Then refer to the bulleted steps as reference once you have the initial basic understanding.

The Keys to Adding Totals to the Stacked Column Chart Above:

  • Add a “Grand Total” column to your data
  • Highlight your data not including the “Grand Total” column
  • On the “Insert” menu select a “2-D Stacked Column” chart
  • Select “Switch Row/Column” as necessary so your first data column is listed on the X axis
  • Select the chart and then expand the data range to include the “Grand Total” column
    • Add “Data Labels” to the Grand Total series on the chart
  • Right click on the Grand Total and “Change Series Chart Type”, the viz becomes a “Combo” chart
  • Change the “Grand Total” series chart type to a “Line”, while leaving all others as a “Stacked Column”
  • Format the line’s data label, changing the Label Position to “Above”
  • Select the line, format the data series and change the “Line” option to “No Line” in order to leave only the totals and hide the line.

The Keys to Adding Totals to the Stacked Bar Chart Above:

  • Add both “Grand Total” and “Spacing” columns to your data
    • Highlight your data including the “Spacing” column but not including the “Grand Total” column
      • The “Spacing” column should have a value of 0 at this point
    • On the “Insert” menu select a “2-D Stacked Bar Chart”
    • Select “Switch Row/Column” as necessary so the “Spacing” values are not listed as an option on the Y axis
    • Change the “Spacing” column values to a number (e.g., 1000) big enough to make a new category visible on the stacked bar chart
    • Right click to “Format Data Labels” and change the “Label Options” to “Value from Cells”
      • In the “Select Data Label Range” pop up box, highlight the values from the “Grand Total” column
      • Change the “Label Position” to “Inside Base”
    • On the chart select the Grand Total Series and right click so the “Fill” option appears
      • Change the “Fill” to “No Fill”
    • Change the values in the “Spacing” column to 0
    • Delete the “Grand Total” entry from the Legend

You can thank me by liking and subscribing to my YouTube Channel

All views and opinions are solely my own and do NOT necessarily reflect those my employer.

Do Great Things with Your Data

– Anthony B. Smoak

shop.spreadshirt.com/AnthonySmoak

INCREASE YOUR FOCUS TRY BRAIN.FM

When I am focusing hard during the day at work or developing visualizations on the weekend. I use Brain.fm to help me focus when it matters. It’s Science-driven and research-backed functional music designed from the ground up to help you you focus, relax, meditate and sleep. If you’d like to try a free trial check out https://brain.fm/anthonyb

Please use coupon code anthonyb for a 20% discount upon checkout. It helps support this blog and my YouTube channel as I receive a small commission for purchases made through links in this post.

Drill from Region to State Using Parameter Actions in Tableau

When the data goes high, you can go low; to misquote a common saying. In this video I’ll show you how to start at a region level on your Tableau map and then drill into the State.

If you’re using the Tableau Superstore data set, make sure the Region and State fields are assigned to a geographic role. Most likely you will need to change the Region to a geographic role, which is created from the State field.

At a high level we’ll have a dual axis based upon the latitude, with the top latitude displaying the regions and the bottom latitude displaying the state. When we layer them on top of each other, we begin to create the illusion of the drill.

We’ll use a parameter creatively named [Region Parameter] which contains all of the regions. From there we’ll create a calculated field named [_States to show] as follows:

If [Region]=[Region Parameter]
Then [State]
END

In order to institute the drill, we’ll create a worksheet parameter action that will change the value of the region parameter on user selection. This causes the clause (If [Region]=[Region Parameter]) to evaluate to TRUE which then causes the display to show the states for the selected region.

It sounds more complicated than it is, so just make sure to watch the video for understanding and clarity.

As a bonus, I’ll show you how to achieve this effect where the selected region does not cause the other regions to gray out. Notice on the second map how all the non selected regions do not lose emphasis; this is not the default effect. It’s the little “show-off” details like this that can up your Tableau game. You’re welcome!

You can thank me by watching, liking and subscribing:

All views and opinions are solely my own and do NOT necessarily reflect those my employer.

Do Great Things with Your Data

Anthony B. Smoak

How to Filter your Tableau Viz in Tooltip (Top 10 Values)

Visualizations in tooltips, affectionately know as “Viz in tooltip” is a handy feature available in Tableau that enables “details on demand” functionality. As the user hovers over a specific mark or data point, additional details are revealed that are filtered specifically for that mark from another worksheet.

In the example above, as the user hovers over a bar, they obtain additional details about the three most profitable products associated with the respective bar.

As I learned in a very informative Tableau presentation for tooltip wonks (myself included), the underlying architecture is built upon action commands and shares many commonalities with action filters. For viz in tooltip performance considerations, use smaller and fewer visualizations. Also try to avoid maps and other complex visualizations that have significant mark density.

If your tooltip responsiveness is greater than 2 seconds or the height and or width is greater than 600 pixels, then consider rethinking your approach. According to Tableau best practice, users are not willing to wait more than 2 seconds hovering over a mark for a reveal.

Since the viz in tool tip passes filters between worksheets, this means we can make use of context filters (click this link for a fantastic overview) to limit the number of marks returned and help improve performance.

This is the Section You are Here for

Context filters also help solve the problem of returning the Top N records associated with a mark. When you assign a viz in tooltip on your source sheet, a set filter is applied on the target (i.e., viz in tooltip) worksheet. If you’re a frequent watcher of my videos you know that the Tableau order of operations prevents the default set filter from returning a proper Top N.

By adding the set filter to the context on the Order of Operations skyscraper, the data is pre-filtered by your dimension first (e.g., State) and then the Top N filter is applied. When the set filter turns gray, you know it’s working.

Notice that the Context Filter box is above the Sets entry; which means that the Context filter is evaluated BEFORE the set. Make sure to watch the video to learn how to limit to the Top 10 cities based upon a hovered state.

Check out the video for details and may all your viz in tooltips be context appropriate!

All views and opinions are solely my own and do NOT necessarily reflect those my employer.

Do Great Things With Your Data

-Anthony B. Smoak