# How To get a column per field count

**URL:** <https://community.grafana.com/t/how-to-get-a-column-per-field-count/8965>\
**Category:** Elasticsearch\
**Created:** [July 19, 2018, 12:22pm UTC](https://community.grafana.com/t/how-to-get-a-column-per-field-count/8965 "2018-07-19T12:22:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![c999chris](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@c999chris](https://community.grafana.com/u/c999chris)\
**Post date:** [July 19, 2018, 12:22pm UTC](https://community.grafana.com/t/how-to-get-a-column-per-field-count/8965/1 "2018-07-19T12:22:26Z")

</div>

Hi,

I have some elasticsearch data I am trying to present in Grafana, here’s an abridged example of some docs:

{  
“\_id”:1,  
“name”: “foo”,  
“location”:“hastings”}  
{  
“\_id”:2,  
“name”: “foo”,  
“location”:“brighton”  
}  
{  
“\_id”:3,  
“name”: “foo”,  
“location”:“eastbourne”  
}  
{  
“\_id”:4,  
“name”: “foo”,  
“location”:“brighton”  
}

What I’d like to see in Grafana is a table panel something like:

```
| name | hastings | brighton | eastbourne |
| foo | 1 | 2 | 1 |

```

Any idea on how to write a query like this, I am really struggling!

---

<div class="post-metadata">

**Author:** ![anon34853223](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@anon34853223](https://community.grafana.com/u/anon34853223)\
**Post date:** [August 1, 2018, 9:00am UTC](https://community.grafana.com/t/how-to-get-a-column-per-field-count/8965/2 "2018-08-01T09:00:07Z")

</div>

There’s no easy way of writing such a query in Grafana I’m afraid.
