Lift a chestnut! Tableau Trise (139): Highlight the line or column of text table

发布于: 2021-06-11

Previously, we shared how to add operation and control set highlight data. Guangzhou users feedback: Our company's data is not very large, analysis is relatively simple, often using text tables (as shown below). However, when reporting to the leader, it is not very convenient.

If you can highlight a row or a column in the text table, it is more intuitive!

This scene seems to be ordinary, but it is generally existed in actual business analysis. Today, let's share how to highlight the way the text table highlight the row or column.

The Tableau tricks we have to share with you this issue are: Highlight the line or column of the text table.

For the convenience of learning, chestnuts use Tableau to own the "example-supermarket" data source. After mastering the chestnut method, the data powder can try to use its own data.

Specific steps are as follows:

1、Create a text table

Open Tableau Desktop, connect "Example - Supermarket" data source, create a new worksheet.

Drag and drop the dimension "region" to the column, drag the dimension "subcategory" to the line, and then drag and drop the metric "Sales" to the text of the "Mark" card, the following text table appears in the worksheet view.

2、Create a calculation field

Right-click on the "Data" pane, select "Create" - "Calculate Field" in the drop-down menu. In the pop-up dialog box, name is computed: display color, type function:

IF [Region] = "North China" THEN 1 ELSE 0 END

Next, drag and drop the created calculation field "Display Color" into the color of the "Tag" card. Right click on the capsule, in the drop-down menu, change the metric to: minimum.

Click Color on the Tag, select Edit Colors, in the pop-up dialog box, you can choose the color. Here, we choose "Custom Dispersion" in the "Color" and select 2 steps of graded colors.

We can choose two ways of highlighting: text color or text background. Just need to select a different tag type in the Tags card.

☟ Tag type selection: square

☟ Tag Type Selection: Text

After the steps, we will expand with the "text background" presentation.

Next, click the top menu bar, select "Analyze" - "Edit Calculation Field" - "Display Color", in the pop-up dialog box, type function:

IF [Region] = "North China" OR [Subcate] = "Apparatus" THEN 1 ELSE 0 END

At this time, we have realized the presence of a highlighting line + column. However, if you want more flexible selection, you should use the parameters!

3、Create parameters

In the "Data" pane, right click on the dimension "Category", select "Create" - "Parameters" in the drop-down menu. In the pop-up dialog box, the parameter is named: the area parameters, select the data type as: string, and the allowed value is selected: list, from the field Add: region.

In the same way, create a subclass of parameters, name the parameters: subcategory parameters, select the data type as: string, select the allowed value to: list, add: subcategory.

The last step: modify the "display color" calculation field that has just been created.

Click on the top menu bar "Analysis", select Edit Calculation Field - "Display Color". In the pop-up dialog box, type a function:

IF [Region] = [Regional Parameter] OR [Subcategory] = [Subcategory Parameter] THEN 1 ELSE 0 END

In this way, we can use colors, flexibly choose the row or column you want to stand! Highlight the color, you can modify it according to your needs ~

This issue of Tableau skills, have you get? Try it quickly!