# Percentage in each group

**URL:** <https://discuss.elastic.co/t/percentage-in-each-group/353882>\
**Category:** Kibana\
**Created:** [February 22, 2024, 12:13pm UTC](https://discuss.elastic.co/t/percentage-in-each-group/353882 "2024-02-22T12:13:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Senol\_Kurt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senol_kurt/32/113382_2.png) [@Senol\_Kurt](https://discuss.elastic.co/u/Senol_Kurt)\
**Post date:** [February 22, 2024, 12:13pm UTC](https://discuss.elastic.co/t/percentage-in-each-group/353882/1 "2024-02-22T12:13:56Z")

</div>

i have an index that holds monthly product sales data for several cities. i want to display in a table the monthly percentage of each product sales in each city. how can i do that?

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [February 24, 2024, 1:14am UTC](https://discuss.elastic.co/t/percentage-in-each-group/353882/2 "2024-02-24T01:14:08Z")

</div>

This is generally doable with Lens and TSVB but I would require a few more details in order to give you a nice guide.  
How do you need the split for the percentage to be done? Is it a percentage of that product from the total sales in that city? percentage of the product in total sales of that product across all cities? percentage of the product relative to the total sales of all products in all cities?

---

<div class="post-metadata">

**Author:** ![Senol\_Kurt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senol_kurt/32/113382_2.png) [@Senol\_Kurt](https://discuss.elastic.co/u/Senol_Kurt)\
**Post date:** [February 25, 2024, 6:13am UTC](https://discuss.elastic.co/t/percentage-in-each-group/353882/3 "2024-02-25T06:13:12Z")

</div>

> [@Senol\_Kurt](#):
>
> have an index that holds monthly product sales data for several cities. i want to display in a table the monthly percentage of each product sales in each city. how can i do that?

it is the percentage of that product from the total sales in that city for each month. below is a sample doc. there are sales data for multiple products, multiple cities and multiple months. i want to get percentage of laptop sales in each city for each month.

```auto
{
  "_index": "sales",
  "_id": "2023-11_laptop_newyork",
  "_version": 1,
  "_score": 0,
  "_source": {
    "product": "laptop",
    "city": "newyork",
    "quantity": 1000,
    "year": "2023",
    "month": "11",
    "yearmonth": "2023-11",
    "createdon": "2024-02-15T06:34:00"
  },
  "fields": {
    "year": [
      "2023"
    ],
    "product": [
      "laptop"
    ],
    "quantity": [
      1000
    ],
    "yearmonth": [
      "2023-11"
    ],
    "year.keyword": [
      "2023"
    ],
    "createdon": [
      "2024-02-15T06:34:00.000Z"
    ],
    "month.keyword": [
      "11"
    ],
    "city": [
      "newyork"
    ]
  }
}

```

---

<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:** [March 24, 2024, 6:13am UTC](https://discuss.elastic.co/t/percentage-in-each-group/353882/4 "2024-03-24T06:13:24Z")

</div>

Closed on March 24, 2024, 6:13am UTC

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