# Functions, in my queries? https://www.sanity.io/learn/course/between-groq-and-a-hard-place/functions-in-my-queries.md With GROQ you can do more than return values; you can compute and transform them from within the query. GROQ offers a [number of Functions](https://www.sanity.io/docs/groq-functions) that you can experiment with. These will save you from needing to "post-process" data in your front end or API to shape data as desired from within the query. Here are a few simple examples: 1. `count()` all the `event` documents in the dataset ```json count(*[_type == "event"]) ``` 1. `coalesce()` takes any number of arguments and returns the first one that isn't `null` – use it to return the `venue` name if defined, otherwise the string "To be confirmed" ```groq *[_type == "event" && eventType == "in-person"]{ "venue": coalesce(venue->name, "To be confirmed") } ``` If you have completed [Handling schema changes confidently](https://www.sanity.io/learn/course/handling-schema-changes-confidently) `eventType` might now be named `format` – adjust the query above accordingly. 1. `defined()` returns `true` for values that are **not** `null` – query for `event` documents that have a `headline` artist defined ```groq *[_type == "event" && defined(headline)] ``` 1. Return an array of unique `headline` `artist` names that have upcoming events ```groq array::unique( *[ _type == "event" && date > now() && defined(headline) ].headline->name ) ``` This is just scratching the surface! There are functions for geolocation, weighted search, the delta between documents as they change in functions – and more!