知識庫

Make Aggregation Results of Multiple Lines into One Line


發佈時間 : 09 Sep 2022
上次修改日期 : 09 Dec 2022

問題

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

Before
User-added image
After
User-added image

環境

  • Tableau Desktop 2022.2

答案

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.
 
這篇文章是否解決了問題?