Power BI Tip: Creating Dynamic Tooltips Using CONCATENATEX DAX Function
Tooltips in Power BI are often overlooked but are a powerful feature that can deliver detailed information at a glance. By default, tooltips show basic data related to the visual element being hovered over. However, when working with complex datasets, you might want to display more specific details, such as a breakdown of sales by different dimensions (e.g., product colors) within a single category. This is where DAX functions like CONCATENATEX
come in handy.
In this blog post, we will explore how to use the CONCATENATEX
function to create dynamic, multi-line tooltips in Power BI. We will guide you step-by-step through a real-world example of showing detailed sales data by product color in a tooltip for a category sales chart.
Why Use CONCATENATEX
for Tooltips?
The CONCATENATEX
DAX function allows you to concatenate values from multiple rows into a single string, separated by a delimiter of your choice. This makes it ideal for showing multiple values in a Power BI tooltip. For example, you can use it to display the breakdown of sales for each product color when hovering over a product category.
With this approach, you can provide users with more detailed information without cluttering the main visual or requiring them to click through to additional reports. Everything is accessible directly from the tooltip!
Scenario: Displaying Sales by Product Color in a Tooltip
Let’s say you have a column chart that shows total sales by product category, and you want to enhance the tooltip to show a breakdown of sales by color for each category. This will help the user quickly identify which colors are driving the most sales in each category.
Step-by-Step Example: Creating a Dynamic Tooltip
1. Setting Up the Visual
In our example, we have a simple column chart that displays the total sales amount for various product categories, such as:
Audio
TV and Video
Computers
Cameras and Camcorders
Cell Phones
Music, Movies, and Audio Books
Games and Toys
Home Appliances
By default, when you hover over one of these bars, the tooltip will only show the overall sales for that category. However, we want to go a step further and show a detailed breakdown of sales by product color for each category in the tooltip.
2. Writing the DAX Formula
To achieve this, we will use the CONCATENATEX
function. This function will create a single string that combines each product color and its corresponding sales amount, separated by a line break. Here is the DAX formula for the enhanced tooltip:
_TooltipColor =
CONCATENATEX(
VALUES('Product'[Color]),
'Product'[Color] & ": " & FORMAT([Sales Amount], "#,0.00"),
UNICHAR(10)
)
Let’s break down the formula:
VALUES('Product'[Color]): This returns a list of unique colors for the selected product category.
'Product'[Color] & ": " & FORMAT([Sales Amount], "#,0.00"): For each color, we concatenate the color name with the corresponding sales amount. We use the
FORMAT
function to ensure the sales amount is properly formatted with commas and two decimal places.UNICHAR(10): This inserts a line break between each color and sales amount, making the tooltip more readable.
3. Adding the Tooltip to Your Visual
Now that we have our DAX formula, we can add the tooltip to the chart. Here's how to do it:
Go to your chart and click on the “Format” pane.
Under “Tooltip,” ensure that it is set to "On."
Go to the "Fields" section, and drag the
_TooltipColor
measure into the “Tooltip” field well.Power BI will now display the detailed sales breakdown for each product color when you hover over a bar in the chart.
4. Result: Enhanced Tooltip in Action
Once you've added the formula and configured the tooltip, you’ll notice that when you hover over any category in the chart, the tooltip will display a detailed breakdown of sales by color.
For example, when hovering over the "Home Appliances" category, the tooltip will look like this:
Category: Home Appliances
Sales Amount: 1,895,771.88
Silver: 396,633.25
Blue: 306,529.97
White: 300,133.29
Red: 178,789.01
Black: 87,293.21
Green: 191,339.54
Orange: 91,980.16
Pink: 34,840.46
Yellow: 11,171.86
Purple: 59.98
Brown: 32,610.32
Grey: 262,282.53
Gold: 2,108.31
This enhanced tooltip provides the user with a much clearer picture of which colors are driving sales for each category, without having to navigate away from the visual.
Benefits of Using CONCATENATEX
in Tooltips
The dynamic tooltips created with CONCATENATEX
provide several key benefits:
Enhanced User Insights: Users can see more detailed information without having to click through multiple layers of a report. In this case, they can see the breakdown of sales by color for each category in one view.
Better Data Visualization: Instead of adding multiple visuals to display color-level sales, you keep your report clean and focused, while still delivering detailed insights.
Customizable Tooltips: The
CONCATENATEX
function allows you to format the content of the tooltip exactly as you want, whether it’s the order of values, formatting numbers, or inserting line breaks for clarity.Improved Performance: By embedding detailed data into the tooltip rather than adding more visuals, you can improve report performance and reduce unnecessary complexity.
Conclusion
Tooltips in Power BI are a powerful yet often underutilized feature. By using DAX functions like CONCATENATEX
, you can create dynamic, customized tooltips that enhance the user experience and deliver meaningful insights at a glance. Whether you are displaying sales by color, region, or any other dimension, this approach helps keep your visuals clean and informative.
Try implementing CONCATENATEX
in your Power BI reports to take your tooltips to the next level!
Bonus Tip
If you're working with a large number of values, consider applying filters or thresholds within the CONCATENATEX
expression to limit the number of rows displayed in the tooltip. For example, you could show only the top 5 products or colors based on sales.
Thanks for Reading !!!
Subscribe to my newsletter
Read articles from Nalaka Wanniarachchi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Nalaka Wanniarachchi
Nalaka Wanniarachchi
Nalaka Wanniarachchi is an accomplished data analytics and data engineering professional with over 18 years of experience. As a CIMA(ACMA/CGMA) UK qualified ex-banker with strong analytical skills, he transitioned into building robust data solutions. Nalaka specializes in Microsoft Fabric and Power BI, delivering advanced analytics and engineering solutions. He holds a Microsoft certification as a Fabric Analytic Engineer and Power BI Professional, combining technical expertise with a deep understanding of financial and business analytics.