KNOWLEDGE BASE

Make Aggregation Results of Multiple Lines into One Line


Published: 09 Sep 2022
Last Modified Date: 10 Sep 2022

Question

How to make aggregation results of multiple lines to be displayed into one line.

Before
User-added image
After
User-added image

Environment

  • Tableau Desktop 2022.2

Answer

Method 1

Create a "Group" manually.

1. Multi-select the lines you would like to merge and chose the group icon from the menu.

User-added image
2. Rename the group if needed by editing the group generated.
User-added image
User-added image

If there are many subcategories to be merged, this method may not be suitable and Method 2 a better choice.

Method 2

Create a calculated field and display the sub categories as details.

1. Create a FIXED LOD to display the Sum of Sales:
Calculation name: SALES
Formula: ROUND(SUM({ FIXED [Category]:SUM([Sales])}))

2. Convert SALES to a discrete measure and drag it to the Rows shelf.

To separate the sub-category with commas,  perform Step 3 - Step 6 below.

3. Create a calculated field named Sub-Category(comma separated)
Formula:
IF LAST()=0 THEN MIN([Sub-Category])
ELSE MIN([Sub-Category])+","
END

4. Drag Sub-Category(comma separated) and drop it to Text on the Marks card.

5. Drag and drop Sub-Category to Detail on the Marks card.

6. Edit the table calculation direction of Sub-Category(comma separated) as shown below:
User-added image
User-added image

If a comma delimiter is not needed, drag and drop Sub-Category to the Text on the Marks card without Step 3 - Step 6.

Please see the sample.twbx for more information.
 
Did this article resolve the issue?