# How to use where function?

**URL:** <https://discourse.gohugo.io/t/how-to-use-where-function/23436>\
**Category:** support\
**Created:** [February 13, 2020, 2:30pm UTC](https://discourse.gohugo.io/t/how-to-use-where-function/23436 "2020-02-13T14:30:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyusan](https://avatars.discourse-cdn.com/v4/letter/k/d78d45/32.png) [@kyusan](https://discourse.gohugo.io/u/kyusan)\
**Post date:** [February 13, 2020, 2:30pm UTC](https://discourse.gohugo.io/t/how-to-use-where-function/23436/1 "2020-02-13T14:30:15Z")

</div>

Hi,

I have some troubles with the where function. I’m listing a list of seismic event based on a param :

content/events/2343/index.en.md

```auto
{
  "automatic": false,
  "eventType": "earthquake",
  "id": 2343,
  "latitude": -39.42,
  "longitude": 173.3,
  "magnitude": 5.6,
  "magnitudeType": "mb",
  "publishDate": "2013-02-16T05:15:33.659999Z",
  "timezone": "Pacific/Auckland",
  "url": "/en/events/2343",
  "zones": [
    "monde"
  ]
}

```

eventType can be equal to “quarryblast”, “earthquake” and so on.

I try in my template to filter on this parameters with the following code :

```auto
{{ $limit := 40 }}
{{ $last_events := first $limit .Data.Pages }}
{{ $earthquakes := where $last_events "Params.eventType" "eq" "earthquake" }}

```

I’ll get an empty array while if I range over $last\_events :

```auto
{{ range $last_events }}
<p>{{ .Params.eventType }}</p> 
{{ end }}

```

I get a list 🙂

```auto
quarry blast
induced
explosion
earthquake
earthquake
earthquake
earthquake
quarry blast
quarry blast
quarry blast
earthquake
earthquake
quarry blast

```

What I’m doing wrong ? I also tried with “.Params.eventType” :

```auto
{{ $earthquakes := where $last_events ".Params.eventType" "eq" "earthquake" }}

```

But that changed nothing ;/

Thank you for your help in advance ! I’m starting to loose my mind 🙂

---

<div class="post-metadata">

**Author:** ![setphen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/setphen/32/10385_2.png) [@setphen](https://discourse.gohugo.io/u/setphen)\
**Post date:** [February 13, 2020, 3:44pm UTC](https://discourse.gohugo.io/t/how-to-use-where-function/23436/2 "2020-02-13T15:44:30Z")

</div>

You need to access `eventType` with a lowercase accessor `.Params.eventtype`

> Page-level `.Params` are _only_ accessible in lowercase.

> **[Page variables](https://gohugo.io/variables/page/#page-level-params)**
>
> Use these methods with a Page object.

It’s sort of silly, so no wonder you were starting to lose your mind a little bit. 😄

---

<div class="post-metadata">

**Author:** ![kyusan](https://avatars.discourse-cdn.com/v4/letter/k/d78d45/32.png) [@kyusan](https://discourse.gohugo.io/u/kyusan)\
**Post date:** [February 13, 2020, 3:50pm UTC](https://discourse.gohugo.io/t/how-to-use-where-function/23436/3 "2020-02-13T15:50:22Z")

</div>

Thank you, it works !

It’s quite disturbing as you can use the camel case name in the template and it works.

---

<div class="post-metadata">

**Author:** ![kyusan](https://avatars.discourse-cdn.com/v4/letter/k/d78d45/32.png) [@kyusan](https://discourse.gohugo.io/u/kyusan)\
**Post date:** [February 13, 2020, 3:54pm UTC](https://discourse.gohugo.io/t/how-to-use-where-function/23436/4 "2020-02-13T15:54:50Z")

</div>

I think, I’ll only simply use lower case names for now, that’ll be easier 🙂

---

<div class="post-metadata">

**Author:** ![setphen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/setphen/32/10385_2.png) [@setphen](https://discourse.gohugo.io/u/setphen)\
**Post date:** [February 13, 2020, 3:58pm UTC](https://discourse.gohugo.io/t/how-to-use-where-function/23436/5 "2020-02-13T15:58:19Z")

</div>

> It’s quite disturbing as you can use the camel case name in the template and it works.

Indeed. This might be a bug. I would expect this to fail when simply doing `{{ .Params.eventType }}` or using `.Params.eventType` inside of `where`, based on the note in the docs.
