简体   繁体   中英

How to group rows in Tableau into bands?

I'm fairly new to tableau and I'm having the following issue. Below is a sample of the data I'm using.

Count | Item
___________________
 1            A
 3            B
 2            C
 3            D
 5            E
 2            F
 5            G
 9            H

I'm trying to group some of these together so I can show a stacked bar chart of these groups like the following:

 Count | Item
    ___________________
     6            A-C
     10            D-F
     14            G-H

How to do this?

Use Tableau's built-in Create Group feature

View and download the solution workbook on Tableau Public: https://public.tableau.com/profile/fosstin#!/vizhome/HowtoGroupYourDatainTableau/Dashboard-HowtoGroupYourData

  1. Right-click the Item dimension and choose Create > Group. This will open the Create Group dialog window.
  2. At the top of the window, in the Field Name text field, enter a name for your grouped dimension or use the default title provided by Tableau, which is Item (group)
  3. Select the first set of letters you wish to group, then click the Group button. Multiselect rows by holding down the control key or the shift key.
  4. Type in a name for the group(ie AC) and press enter.
  5. Repeat steps 5 and 6 to create the DF and GH groups, then click OK.
  6. Drag the Item (group) dimension to the Rows shelf and the Count measure to Text in the Marks card.
  7. Add a column header to the Count column by double-clicking Measure Values in the data pane.
  8. Right-click the Measure Values pill now on the Marks card and choose Format. Then, in the formatting pane, choose Numbers > Number (Standard)

References:
Tableau Help: Group Your Data
https://help.tableau.com/current/pro/desktop/en-us/sortgroup_groups_creating.htm#create-a-group-from-a-field-in-the-data-pane

Tableau.com Blog: The one-click trick for create headers for single-measure tables
https://www.tableau.com/about/blog/2015/11/how-create-fast-headers-single-measure-tables-45945

You can use a CASE statement to create the groups. I named it group in my example.

CASE [Item]
    WHEN 'A' THEN 'A-C'
    WHEN 'B' THEN 'A-C'
    WHEN 'C' THEN 'A-C'
    WHEN 'D' THEN 'D-F'
    WHEN 'E' THEN 'D-F'
    WHEN 'F' THEN 'D-F'
    WHEN 'G' THEN 'G-H'
    WHEN 'H' THEN 'G-H'
END

Then add group to your Rows shelf and Count to your text.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM