There came a question regarding "Lookup via Association". I have seen similar questions a while ago. I almost forgot how I solved them before. This time I will write it down.

Problem Statement

Given a customer who is from some state(s). We would like to see all the other customers from the same state(s). (Plural because the customer may have been migrating from one state to another along the years.) This customer and the other customers are associated by state(s). Through this association, we want to look up who else are from the same state(s).

There are two approaches to solve the problem. The first needs to duplicate the data source. It is easy to understand. The second is based on a single data source and needs table calculations. We will use the superstore data set in the examples.

1. Duplicate Source Approach

We duplicate the data source so that we can perform a subquery on one to get the State(s), then perform the main query on the other data source using the State(s).

The main steps are
- Create a Customer Name parameter with all the Customer Name list.
- In the Superstore Copy data set, create a field Show State
- Create a Data>Relationships between Show State in Superstore Copy and State field in Superstore.
- Use Superstore data set as the primary source to blend with Superstore Copy as the secondary by the above relationship.
- Place Show State in the filter shelf and exclude the Nulls.

This will list all the other customers in the same states as those of the selected customer.

On a separate sheet, we can use a simple filter Match ParaName to show the list of states the selected customer is from:
[Customer Name]=[Parameters].[Customer Name]
This will get the job done. Here is the workbook.

2. One-Source Approach

Some may prefer a single data source. This approach will take advantage of the power of table calculations. A simple table calc will suffice.

2.1 Get the list of states for the selected customer

Use exactly the same filter as in the duplicate source approach to list the states of the selected customer.

2.2 Show all the associated customers

Let's create a new field SelectState:

Then create the following sheet. Set the table calc of SelectState to compute using Customer Name. Exclude the Nulls in the SelectState field. We will get what we need.
The resulting list of associated customers are as follows:
Click the image to see the interactive version.

3.Adding more fields
If we need to add more fields to the table, set them to be attributes (right click & select ATTR()) instead of dimensions. The table calcs are sensitive to dimensions. The added dimensions might mess up the table calculations.

4.Postscript
That's how we can use table calcs to filter the entire table, or use data from a single row to filter other rows. To learn more about table calcs, just google "Tableau Table Calculations".

0

Add a comment

(Refresh the page if you want to view the gif image multiple times. Or go to Tableau Public and click the button at the top-right corner.)

Jake and I collaborated on a dashboard. He told me that he learnt a way to create an in-place help page in Tableau. He first saw it at a conference somewhere and couldn't recall who the speaker was. So I am blogging here about it but the credit goes to somebody else. If anyone knows who the original creator is, leave a comment below.

The key idea is to float a semi transparent worksheet on top of the dashboard, where a help text box is strategically placed on top of each chart. This way, we can explain how to view each chart and what data points are important, etc. This worksheet is collapsible by a show/hide button. 

Below I would like to show how this worksheet can be constructed.

1. Sheet with a single data mark.

  • Double click the empty space in Marks panel and add two single quotes. Make the null pill a text label. This creates a single null mark.
  • Set the view as "Entire View"

2. Create an show/hide button

  • Go to the target dashboard
  • Drag a floating vertical container to the dashboard, making it cover all the area of interest.
  • Drag the Single Null Mark sheet and drop it into the above container. Hide the sheet title.
  • Create an open/close button for the container and place the button at the top-right corner.

3. Add annotations

  • Format the sheet background opacity as 70% in the layout manager             
  • Select area annotations and place them anywhere of interest. 
  • Write help text and format it to highlight important messages.  
  • The text can serve as functional guide and/or insight guide.

Here is an example. Feel free to download the workbook and explore. Click the "i" button at the top-right corner to view the in-place help. 

0

Add a comment

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