# Param dropdown for group\_id in data explorer query

**URL:** https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883
**Category:** Feature
**Tags:** data-explorer, completed
**Created:** [February 2, 2023, 8:03pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883 "2023-02-02T20:03:10Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [February 2, 2023, 8:03pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/1 "2023-02-02T20:03:10Z")

</div>

I’d love to be able to specify something like this:

```plaintext
-- [params]
-- groups.id :group_id

```

to get a parameter input that’s a dropdown of groups. I’ve named the value `group_id` here because I assume that’s what such a dropdown would give me.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [February 18, 2023, 5:46pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/2 "2023-02-18T17:46:30Z")

</div>

I think this would be really useful too. 👍 Something like the existing `user_id` selectable parameter but for groups. Even better if it could accept multiple values. 🙂

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [February 20, 2023, 12:21pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/3 "2023-02-20T12:21:44Z")

</div>

> [@JammyDodger](#):
>
> the existing `user_id` selectable parameter

Wait, what?

Can you point me to where it shows how to use that?

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [February 20, 2023, 12:44pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/4 "2023-02-20T12:44:16Z")

</div>

You can use something like:

```plaintext
-- [params]
-- user_id :user

SELECT *
FROM posts
WHERE user_id =:user
LIMIT 5

```

And that will bring up a dropdown where you can autocomplete in a user. 👍

 ![image](https://global.discourse-cdn.com/meta/original/4X/3/3/c/33c586ec67d7fd7acf26a96814ffffbd2d2f1caf.png)

However, I have just noticed that the first time you run it at the moment it errors and doesn’t bring up the parameter box, but does if you refresh the page. I shall see if I can get someone to check that out. 🙂

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [March 12, 2024, 5:21pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/13 "2024-03-12T17:21:25Z")

</div>

Ask (and wait) and you shall receive… we just added support for a `:group_list` parameter in [this PR](https://github.com/discourse/discourse-data-explorer/pull/283).

Here is an example of the feature in use:

```plaintext
-- [params]
-- group_list :groups

SELECT g.id,g.name 
FROM groups g 
WHERE g.name IN (:groups) 
ORDER BY g.name ASC

```

That should give you the following in the UI:

 ![image](https://global.discourse-cdn.com/meta/original/4X/4/8/6/486c25ba68cc5da8d68a8e77ec40d5bd58ad4623.png)

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [March 12, 2024, 5:22pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/14 "2024-03-12T17:22:46Z")

</div>

This looks great. 🤩 I’m already looking forward to putting this into action. 🚀

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [March 18, 2024, 5:49pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/17 "2024-03-18T17:49:42Z")

</div>

[My topic](https://meta.discourse.org/t/wishlist-param-dropdown-for-data-explorer-query/253883) got closed before I could reply to it…

Is there a way to limit the new `-- group_list` parameter type to a single group? I’ve subbed it into our existing reports, but they’re all written expecting a simgle group name and in testing I found myself flubbing it fairly frequently.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [March 18, 2024, 6:05pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/18 "2024-03-18T18:05:29Z")

</div>

I’ve reopened and slipped it over. 👍

Though I’m not sure what you mean? Can you give an example of what the issue is?

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [March 18, 2024, 6:18pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/19 "2024-03-18T18:18:27Z")

</div>

I mean that I run the query for my first group. Then when I want to _switch_ groups, I add a group instead → error

 ![Selection_1653](https://global.discourse-cdn.com/meta/original/4X/d/e/4/de4238483b196e82ad8a31121565b26f1eae39e1.png)

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [March 18, 2024, 6:25pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/20 "2024-03-18T18:25:08Z")

</div>

Oooh. That’s an interesting one. I’ve been using it more like:

```sql

WHERE g.name IN (:groups)

```

> **Hiding a little bit of Jammy Stupid**
>
> ```sql
> 
> WHERE g.id IN (:groups)
> 
> ```

Though this would still allow you to accidentally put more than one in even though you’d avoid the error. 🤔

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [March 18, 2024, 6:30pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/21 "2024-03-18T18:30:03Z")

</div>

I’d rather have the error than a random selection from the list 🙂

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [March 18, 2024, 6:32pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/22 "2024-03-18T18:32:59Z")

</div>

To be honest, I’ve just checked that and I think I must have dreamt using it for group\_ids as it does not like that at all. I shall strike that from the record. 🙂 No idea where I’ve got that idea from. I could’ve sworn I used it just the other day. :derp:

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [March 18, 2024, 6:41pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/23 "2024-03-18T18:41:57Z")

</div>

BTW, I completely neglected to say:

This is fabulous!!! 🎊 Thank you!!! 🎉

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [March 18, 2024, 7:12pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/25 "2024-03-18T19:12:41Z")

</div>

> [@ganncamp](#):
>
> Is there a way to limit the new `-- group_list` parameter type to a single group?

No, there’s no way to limit it to a single group. Not that I know of.

The parameter from `group_list` will be an array if there is more than 1 item selected and a string if only 1 item is selected.

So when there is just one item, you _can_ do this:

```plaintext
-- [params]
-- group_list :groups

SELECT g.id,g.name 
FROM groups g 
WHERE g.name = :groups 
ORDER BY g.name ASC

```

But since it’s an array, this below will work for both a single item and multiples:

```plaintext
-- [params]
-- group_list :groups

SELECT g.id,g.name 
FROM groups g 
WHERE g.name IN (:groups)
ORDER BY g.name ASC

```

But there is no way to tell the UI “only accept 1 item as the selection”.

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [August 2, 2024, 1:21pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/28 "2024-08-02T13:21:04Z")

</div>

@saradev’s docs here [Using Parameters in Data Explorer Queries](https://meta.discourse.org/t/utilizing-parameters-in-data-explorer-queries/277934) highlights the full list of params for [data explorer](https://meta.discourse.org/t/32566?silent=true) that sometimes have a dropdown, and sometimes do not. ([Parameter list on Github](https://github.com/discourse/discourse-data-explorer/blob/6aca7f1ae42bd7c1880e91c136ed99babc146d2e/lib/discourse_data_explorer/parameter.rb#L42-L64))

Here’s a table of params, also indicating if it has a specific control for it.

| param | dropdown available |
| --- | --- |
| int | ✅ |
| bigint | ✅ |
| boolean | ✅ |
| null boolean | ✅ |
| string | ✅ |
| date | |
| time | |
| datetime | |
| double | ✅ |
| user\_id | ✅ |
| post\_id | |
| topic\_id | |
| string\_list | |
| category\_id | |
| group\_id | |
| int\_list | |
| string\_list | |
| user\_list | ✅ |
| group\_list | ✅ |

Ideally the dropdowns used and shown in [data explorer](https://meta.discourse.org/t/32566?silent=true) would have similar look and feel as the core app. Let us figure out how we can do this.

---

<div class="post-metadata">

### Author: ![Lhc\_fl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lhc_fl/32/268115_2.png) [@Lhc\_fl](https://meta.discourse.org/u/Lhc_fl)
#### Post date: [August 27, 2024, 5:27am UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/40 "2024-08-27T05:27:39Z")

</div>

We recently redesigned the entire param input box. Most types have their own drop-down boxes and support validation with semantic error prompts now. :chefs_kiss:

 ![The image shows a screenshot of a user error page, indicating that the form contains errors and needs to be fixed. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/7/8/d/78d656493ee2a486368b45d3ded5ae53404cf317.png)  
 ![The image displays a form with two input fields for the string "123456789" and the bigint "123456789". (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/b/9/c/b9c945d39124aab673b5ea4f76a4559752f39e81.png)

Here’s the latest table of params indicating if it has a specific control for it.

| param | dropdown available |
| --- | --- |
| int | ✅ |
| bigint | ✅ |
| boolean | ✅ |
| null boolean | ✅ |
| string | ✅ |
| date | ✅ |
| time | ✅ |
| datetime | ✅ |
| double | ✅ |
| user\_id | ✅ |
| post\_id | |
| topic\_id | |
| category\_id | ✅ |
| group\_id | ✅ |
| int\_list | |
| string\_list | |
| user\_list | ✅ |
| group\_list | ✅ |

@ganncamp You might want to know about this change 😉

---

<div class="post-metadata">

### Author: ![jordan-violet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan-violet/32/281428_2.png) [@jordan-violet](https://meta.discourse.org/u/jordan-violet)
#### Post date: [April 17, 2025, 7:35pm UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/41 "2025-04-17T19:35:04Z")

</div>

Can you explain how these dropdowns work? For the life of me I have not been able to get a dropdown where I can define a list of strings available in that dropdown.

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [June 5, 2025, 4:23am UTC](https://meta.discourse.org/t/param-dropdown-for-group-id-in-data-explorer-query/253883/42 "2025-06-05T04:23:41Z")

</div>

@jordan-violet a late response, but @SaraDev did a writeup here on available parameters, and the OP had been updated by Linca:

> [@Using Parameters in Data Explorer Queries](https://meta.discourse.org/t/utilizing-parameters-in-data-explorer-queries/277934):
>
> Parameters are a powerful tool that can be used in [Data Explorer](https://meta.discourse.org/t/32566) queries on Discourse. Parameters allow for more dynamic and customizable queries, and instead of hard-coding values in your queries, you can declare variables that will prompt for input when the query is run. Declaring a Parameter To declare a parameter, you can use the following syntax: -- [params] -- int :parameter\_name = 10 The parameter’s section of the query will always start with -- [params], followed by each type of par…
