Skip to main content

Query items by column value for two different columns

  • December 17, 2021
  • 12 replies
  • 2675 views

  • Participating Frequently

Hi Everyone,

I found a couple of other threads that seem to be asking this same question, but they have been closed and do not offer a solution or a workaround.

I’m wondering if there is a way to write a graphql query for the items on a board that meet criteria for two different columns. The “items_by_multiple_column_values” query allows us to query two different values for one column, but I need to query results that have one value for 1 column AND one value for another column. If this can’t be done with a single query, how might one achieve a similar result?

Thanks in advance for your help!
-max

12 replies

Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • December 20, 2021

Hello @max!

As you said, this can’t be achieved using Monday’s API with one query. What I would do is make two different queries (one for each column value), and then in my server, check the IDs of the items that appear in both responses.

You could also use one query and look for the value in one of those two columns, and retrieve the data inside second column in that query. You would then have to check in the retrieved items which ones also have that specific value in the second column.

I hope this helps!

Cheers,
-Matias


  • Author
  • Participating Frequently
  • December 20, 2021

Hi Matias,

Thanks for the response. This is helpful. I think I will attempt a workaround with the second option you propose.

Best,
Max


  • Author
  • Participating Frequently
  • December 20, 2021

Sorry, @Matias.Monday, how might I do what you suggest above? That is, how could I query one columns values and retrieve the data inside the second column of interest?


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • December 21, 2021

Hello again @max!

You could use a query like this one:

{
  items_by_multiple_column_values(board_id: 123456, column_id: "status", column_values: "Done") {
    id
    column_values(ids: "text") {
      text
    }
  }
}

With this query, you would get the items with the status column set to “Done” and you would get the text column value for all of those items, therefore you could check which items have the text you are looking for and have “Done” at the status column and you would have their IDs.

You could add the IDs of other columns if you need them.

Hope it helps!

Cheers,
-Matias


  • Author
  • Participating Frequently
  • December 21, 2021

Thank you! I’m new to this and was struggling with the column_values field.

Unfortunately, it looks like it’s still going to be a challenge to do what I want, but that seems to be the result of careless design in how we have our information spread across board, along with the limitations of supported columns.

It would be great if mirror and connect boards columns were supported! Thanks again for the help.


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • December 22, 2021

Hello again @max!

I am glad that was helpful. You’ll get there 💪

I hear you. These are requests that our R&D team are aware of and I will make sure to add your vote to them so that hopefully they can be implemented soon.

If you need anything else, you can come back to the community and/or send as an email to appsupport@monday.com

We are here for you!

Cheers,
-Matias


  • New Participant
  • October 17, 2022

Dear @Matias.Monday

Hi, any updates on this matter? Could really be very helpful, to allow at least 2 column_ids[ ]

Kind regards,
KZ


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • October 18, 2022

Hello @Kostas001 and welcome to the community!

I hope you like it here 💪

I do not have an update yet. As soon as there is one, we will post it in our changelog!

Cheers,
Matias


  • New Participant
  • October 18, 2022

Thank you ! Ill keep an eye on it changelog👀


  • New Participant
  • April 17, 2023

It’s quite strange that such a basic capability does not exist in your API. The workaround requires us to use additional resources.
This should be a top priority as it’s really a basic capability I expect to have when using the API


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • April 18, 2023

Hello there @noym,

I will add your vote for this request!

Thank you for the feedback 🙂

Cheers,
Matias


Forum|alt.badge.img
  • monday.com Team Member
  • November 8, 2023

Hi,
Just updating that this is now possible in the new version of the API 🙂 Migration guide - 2023-10