# How to create Sub categories in Data table?

**URL:** <https://discuss.elastic.co/t/how-to-create-sub-categories-in-data-table/352117>\
**Category:** Kibana\
**Created:** [January 30, 2024, 6:27pm UTC](https://discuss.elastic.co/t/how-to-create-sub-categories-in-data-table/352117 "2024-01-30T18:27:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shubhankar](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@Shubhankar](https://discuss.elastic.co/u/Shubhankar)\
**Post date:** [January 30, 2024, 6:27pm UTC](https://discuss.elastic.co/t/how-to-create-sub-categories-in-data-table/352117/1 "2024-01-30T18:27:40Z")

</div>

I have generated a data table using the Kibana 8 lens visualization, but I'm uncertain about adding subcategories to it. Specifically, after including the necessary columns, I aim to further segment the data from the second row onward into distinct categories. Within the 'cnames' field, there is a list of values like 'canpar,' 'Puro,' and 'UPS.' I have attached an image displaying the current table output on the left and the desired output on the right.

Could you please advise on how to accomplish this?

 ![Screenshot 2024-01-31 000349](https://us1.discourse-cdn.com/elastic/original/3X/d/0/d0b8dcc11df932ab43e8695b4f4089cdc3cda897.jpeg)

---

<div class="post-metadata">

**Author:** ![Priscilla\_Parodi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priscilla_parodi/32/43047_2.png) [@Priscilla\_Parodi](https://discuss.elastic.co/u/Priscilla_Parodi)\
**Post date:** [January 30, 2024, 7:13pm UTC](https://discuss.elastic.co/t/how-to-create-sub-categories-in-data-table/352117/2 "2024-01-30T19:13:24Z")

</div>

Hello @Shubhankar,

Welcome to the community!

Just to make sure I understand correctly. I see that by comparing one table with the other (expected output), you have the 'carrier' column instead of the 'ship from/to' columns.

Does the 'carrier' field contain values like 'canpar,' 'Puro,' and 'UPS,' and do you want to split the data table by this term? Or do you want a new table with these subcategories?

Have you tried adding a bucket to split rows with a terms aggregation?

---

<div class="post-metadata">

**Author:** ![Shubhankar](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@Shubhankar](https://discuss.elastic.co/u/Shubhankar)\
**Post date:** [January 31, 2024, 6:32pm UTC](https://discuss.elastic.co/t/how-to-create-sub-categories-in-data-table/352117/3 "2024-01-31T18:32:32Z")

</div>

Yes, the carrier field has values like Canpar, Puro, UPS. I have created a table based on ship from and ship to data. Now further I want to divide by carrier too. Below is screenshot, please check. As you can see the first row is based on the From Province and To province from second row it is further divided based on the carriers. Once done then again it show from another From province and to province and then divide that into carrier wise.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/5/750a987e30c5702d542eb0365b9b7dd5a5459d88.png)

---

<div class="post-metadata">

**Author:** ![Priscilla\_Parodi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priscilla_parodi/32/43047_2.png) [@Priscilla\_Parodi](https://discuss.elastic.co/u/Priscilla_Parodi)\
**Post date:** [January 31, 2024, 7:45pm UTC](https://discuss.elastic.co/t/how-to-create-sub-categories-in-data-table/352117/4 "2024-01-31T19:45:00Z")

</div>

Are you looking for something similar to this?

> <https://github.com/elastic/kibana/issues/69450>
>
> Lens users currently define their aggregations in a column-oriented way. Users s…hould be able to select any of their bucketed columns to be transposed for display purposes- this can be used to make the display more dense. This will be most clear with some examples.
> 
> Here is a relatively small table with 2 buckets and 2 metrics. Because there are 2 buckets, the user can choose the following transpose options:
> 
> \* No transposing
> \* Transpose the first column (date)
> \* Transpose the second column (filters)
> \* Transpose both first and second columns
> 
> \## No transposing
> 
> The original data:
> 
> Date | Filters | Count | Sum
> \-- | -- | -- | --
> 3/24/20 | A | 20 | 102
> 3/24/20 | B | 2 | 23
> 3/25/20 | A | 3 | 50
> 3/25/20 | B | 6 | 81
> 3/26/20 | A | 7 | 97
> 3/26/20 | B | 8 | 12
> 
> \## Transpose the first column
> 
> 
> Filters  | 3/24/20 - Count | 3/24/20 - Sum | 3/25/20 - Count | 3/25/20 - Sum | 3/26/20 - Count | 3/26/20 - Sum
> \-- | -- | -- | -- | -- | -- | --
> A | 20 | 102 | 3 | 50 | 7 | 97
> B | 2 | 23 | 6 | 81 | 8 | 12
> 
> \## Transpose the second column
> 
> Date | A - Count | A - Sum | B - Count | B - Sum
> \-- | -- | -- | -- | --
> 3/24/20 | 20 | 102 | 2 | 23
> 3/25/20 | 3 | 50 | 6 | 81
> 3/26/20 | 7 | 97 | 8 | 12
> 
> \## Transpose first and second columns
> 
> \<span\>\</span\> | 3/24/20 - A | 3/24/20 - B | 3/25/20 - A | 3/25/20 - B | 3/26/20 - A | 3/26/20 - B
> \-- | -- | -- | -- | -- | -- | --
> Count | 20 | 2 | 3 | 6 | 7 | 8
> Sum | 102 | 23 | 50 | 81 | 97 | 12
> 
> \# Implementation note
> 
> I propose that we implement this in \_visualization options\_ for the table visualization, not as a feature of the Lens datasource or Lens editor. The main reason is that we don't need this for other visualizations, since the visual encoding would be the same.
> 
> One requirement that we need to keep is the behavior of applying a filter based on a table cell. The semantics of this should be the same, even though the table cells will be presented in a new order.
> 
> Also, as you can see in the example above, not every transposed table is as dense as others: it's possible that we can recommend the "densest" display of the table by applying some heuristics, such as "suggest that users transpose the column with the lowest expected cardinality"- this will usually not be the date histogram column, but might be the Terms aggregation.

> <https://github.com/elastic/kibana/issues/5049#issuecomment-900552662>
>
> I want to compare between two or more jasons, for that i want to display them in… a pivot table, one next to each other.

But this depends on the version you are using.

---

<div class="post-metadata">

**Author:** ![Shubhankar](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@Shubhankar](https://discuss.elastic.co/u/Shubhankar)\
**Post date:** [January 31, 2024, 8:05pm UTC](https://discuss.elastic.co/t/how-to-create-sub-categories-in-data-table/352117/5 "2024-01-31T20:05:20Z")

</div>

Those two examples are different. What I am expecting is for eg ON to ON the volume is 14506 as i shared in the first screenshot. This volume consist of all the carriers. Now I want to further byfurcate by carriers for eg, Total volume is 14506 out of this lets assume Canpar has 10000, Puro as 4000, UPS has 400. I am using Kibana 8.12

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 28, 2024, 8:05pm UTC](https://discuss.elastic.co/t/how-to-create-sub-categories-in-data-table/352117/6 "2024-02-28T20:05:29Z")

</div>

Closed on February 28, 2024, 8:05pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
