Percentage in each group

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?

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?

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.

{
  "_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"
    ]
  }
}

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