Highlight an entire row in Tableau
In this blog you will learn how to highlight an entire row in Tableau.
Learn how to highlight an entire row in Tableau – via video or blog
Do you prefer to watch a video on the topic instead? Check out my video on YouTube:
Why learn how to highlight an entire row in Tableau?
Why would you want to learn how to highlight an entire row in Tableau?
Great question.
Although using large amounts of tabular data in Tableau is strongly discouraged to those who wish to avoid performance issues, most of us have been in situations when stakeholders insist on adding a large table to a report.
If this happen, providing the user with the ability to highlight an entire row will come in handy,
This trick is especially useful when we are building a table with several columns, maybe even one with a horizontal scroll bar, as it will help the user keep track of which line they are on while they scroll.
Just a heads up: the downside of adding this functionality is that it might further slow down the view. If that happens, consider limiting the amount of cells shown when opening of the report by filtering out the data. For example, you can add a relative date filter that only shows data for the last two weeks. You show the filter command in the view that so that, if needed, the use can select a larger dataset.
Credits
All the credit for this solution goes to Jeffrey A. Shaffer, who posted this solution on his blog. Check out his post for this and more solutions! In this blog i will explain one of the solutions proposed by Jeffrey (solution number 4) and add some observations and limitations of this approach that I have noticed while using it.
How to highlight an entire row
In his blog, Jeffrey bases his solution of a string field called ID.
Truth be told, one can choose to base this solution on other data types. In the sections below, I will show how to base this solution both on ID and date. The process is almost identical.
Overall, what is important is to choose this field based on what we wish to order our table by.
The logic behind this approach
What is the logic behind this approach? In simple words, the idea behind Jeffrey’s brilliant solution to divide the whole table into three sections:
- the rows above the selection
- the selected row
- and the rows below it.
Once the table has been divided into three, you will be able to leverage Tableau’s Row Banding to alternate between colored and uncolored rows.
In short, the row we select will be colored, whereas the ones above (which are considered one large row) and the ones below (also considered one large row) will not be colored.
Brilliant, isn’t it?
So, why do we need to order the table in a specific way?
Due to the calculation used in this solution, the division of the table into three rows depends on the order of the rows. All the values smaller than the selected rows need to be above it, and those larger than the selected row need to be below it.
This is why choosing what to order the table by is crucial. If the table is ordered by something other than the field used in the calculation, selecting a row will reorder all the other rows, sometimes even moving the selected row off screen.
E.g. The table is ordered by date (with a date range between 1/1/2020 and 31/12/2021) but we have based our trick on ID. We select a row with ID number 1235 and date 3/1/2020. Before we click it, the row is the third in the table. After we click on it, the table will be re-ordered by ID, with all the ID smaller than 1235 moving above the selected row. The selected row will then move well out screen, confusing the end user.
OPTION 1: Ordering table by ID
For this option, I will assume your ID field is a string. If not, make sure to change its data type into string.
- Create a Parameter and call it “Select Row”. Choose data type string and allow all values from your ID field e.g. Order ID
- Create a Calculated Field and call it “Color Row”. Type in:
IF [Order ID] < [Select Row] THEN 1 ELSEIF [Order ID] = [Select Row] THEN 2 ELSEIF [Order ID] > [Select Row] THEN 3 END
3. Create the table. Make sure to add “Color Row” as the first column to the left.
4. Format Shading by choosing the desired Row Banding color for both header and Pane
5. Set Row Banding “Level” to 0 and “Band size” to 1
6. Add parameter action
OPTION 1: Ordering table by ID
- Create a Parameter and call it “Select Row”. Choose data type date and allow all values from your date field e.g. Order Date
- Create a Calculated Field and call it “Color Row”. Type in:
IF [Order Date] < [Select Row] THEN 1 ELSEIF [Order Date] = [Select Row] THEN 2 ELSEIF [Order Date] > [Select Row] THEN 3 END
3. Create the table. Make sure to add “Color Row” as the first column to the left.
4. Format Shading by choosing the desired Row Banding color for both header and Pane
5. Set Row Banding “Level” to 0 and “Band size” to 1
6. Add parameter action
Watch out!
If you add a new measure to the table and you notice that the Parameter action no longer works and the rows are alternating between colored and not colored, go bavck to formatting shading and drag the “Level” slider back to zero.
Limitations
- It works in a strange way for the first row (but it shouldn’t really be a problem since it’s easy to follow through the first row even if it’s not highlighted)
- If the columns are re-ordered, it breaks. This is due to the trick behind the highlighter, I can explain it to you in a call cause it’s a bit long. But this is the reason why I created one version ordered by id and one ordred by date. For the purpose of this dashboard, I suggest using the one ordered by date.
Below you can find a dashboard where I have added this feature:
Thank you for reading!
Do you want to learn more about Tableau, Alteryx or Snowflake? Do you want to use these tools to their full potential? Check out our trainings and other services!