Master Paginated Reports In Power BI - Learn with the Nerds FULL COURSE
Welcome to a new series that Iβm starting with a few colleagues at Pragmatic Works. The goal of this series is to document many design practices and solutions to problems that we often run into with customers. Each post will be accompanied by a video (found in the bottom under Resources) that walks you through the solution in depth. I hope you enjoy this new series!
One feature I am a huge fan of is adding fields to a visualizationβs tooltip to help give end users more context to the data they are seeing. Tooltips (as shown below) automatically add fields that are used in the chart, but you also have the option to add additional fields that arenβt used anywhere else in the chart.
Problem
While I do really like this feature, there are also some problems you may run into when using it. Letβs examine the problem:
In this example, I have added the fields Stock and Subcategory from the Fields list. Stock is an implicit measure, which means it is automatically aggregated, and Subcategory, which is a text field.
This works perfectly for Stock because it automatically summarizes the value, but youβll notice above that the tooltip for Subcategory has an interesting behavior. Rather than displaying the list of the values in Subcategory, it only shows the very first value. This happens because the Tooltip field requires that any column used in it will be able to aggregate or roll up the values into whatβs shown on the chart. Since Subcategory is a text field, Power BI automatically applies the FIRST function to return back the first value that appears. You could optionally change this from FIRST to either LAST, COUNT, or COUNTDISTINCT.
So the real problem I want to solve here is, rather than only showing the first subcategory, how do I list all the subcategories in a comma separated list in the tooltip? Letβs walk through a couple of possible designs to this solution.
Design
There are a couple different approaches to solving this problem. One way would be to give every Subcategory a comma separated list. The problem with that is, what if you have 200 subcategories? With 200 subcategories, your tooltip can become even larger than the chart itself. So letβs walk through possible ways of solving this problem. The first method will be a simple design that does not account for the possibility of 200 subcategories. The second method will be a more elegant solution that accounts for a large number of subcategories.
Simple Design
With this simple design, weβve created a small calculated measure that simply concatenates all the values in the Subcategory column together with a comma separator.
Subcategories = CALCULATE(CONCATENATEX(VALUES(βStock'[Subcategory]),βStock'[Subcategory],β, β))
Letβs break this down:
- The CONCATENATEX function is used here to roll up a list of values. In this case, a list of subcategories into a single row with a comma separator.
- The VALUES function is used to return back a distinct list of subcategories. That way we donβt see duplicate values appearing in our comma separated list.
- Finally, the CALCULATE function is used to set the proper row context here. This ensures the list of subcategories are associated with the correct values in the dataset.
This solution is nice, but not perfect. Letβs look at an even better design.
More Elegant Design
In the more elegant design, weβre accounting for the fact that we could have so many subcategories that the tooltip could possibly take over the report. Essentially, weβre using the same strategies as before, but have incorporated a few new tricks.
Subcategories and More =
VAR SubcategoriesCount = DISTINCTCOUNT(βStock'[Subcategory])
RETURN
IF(SubcategoriesCount >= 3,
CALCULATE(CONCATENATEX(TOPN(3,VALUES(βStock'[Subcategory])),βStock'[Subcategory],β, β))&β and moreβ¦β,
CALCULATE(CONCATENATEX(VALUES(βStock'[Subcategory]),βStock'[Subcategory],β, β))
)
Letβs review this design:
- This time a variable is used. This is done to make things a little easier to follow, but not a mandatory part of the design.
- Next, we utilize an IF statement with the intent to check the number of distinct subcategories that are found. The IF statement returns back TRUE or FALSE to the question, βAre there greater than or equal to 3 subcategories?β
- If the answer to that question is TRUE, then we send it through a process that only returns the top 3 subcategories. It would also return back the text β and moreβ¦β after the top 3 values.
- If the answer to the IF statement is FALSE, then it would perform the CONCATENATEX function just like we saw in our simple design shown earlier.
Both of these designs solve this problem effectively, but letβs see what the final solution looks like.
Solution
The final step is to pull the entire solution together. This step is simple because the only requirement is to add either of the two new fields discussed above to the tooltip area of the chart.
In this example, Iβve added the Subcategories and More fields, which check how many distinct subcategories there are, and if there are more than 3, cuts off the list there.
Summary
Leveraging tooltips in Power BI gives you the ability to display additional information about the data your users are looking at. Leveraging DAX can take this to the next level. In this scenario, we showed how DAX helped to display multiple items in a comma separated list rather than showing the first or last value of that list.
Resources
Video of solution:
- Dataset β Inventory Stock.xlsx
- Completed Example β 01 β Concatenated Tooltip.pbix
Sign-up now and get instant access
ABOUT THE AUTHOR
Devin Knight is a Microsoft Data Platform MVP, Microsoft Certified Trainer, and President of Pragmatic Works. He focuses on driving adoption of technology through learning. He is an author of nine Power Platform, Business Intelligence, and SQL Server books. He has been selected as a speaker for conferences like Power Platform Summit, PASS Summit, SQLSaturdays, and Code Camps for many years. Making his home in Jacksonville, FL Devin is a contributing member to several local user groups.
Free Community Plan
On-demand learning
Most Recent
private training


Leave a comment