cancel
Showing results for 
Search instead for 
Did you mean: 

How to fetch all matching records using data_table_lookup?

Bhagya_pola
Deputy Chef III
Deputy Chef III

 

Hello Team,

Has anyone worked with the data_table_lookup formula in Workato?

I'm trying to fetch multiple records from a data table based on a condition, but it seems to only return the first matching record, not all.

Here’s an example of my data table:

Student Name Class Course Joined

StudentNameClassCourse Joined
Student17thPython
Student26thJava
Student37thJava
Student410thJavaScript
Student510thHTML & CSS
Student610thPython
Student78thJavaScript

(Assume this table is sorted by Created Time in ascending order.)

When I use the formula below to fetch student names who joined the Python course, I only get the first matching record:

data_table_lookup("<datatable folder path>", "StudentDetails", CourseJoined: "Python")["StudentName"]

This only returns Student1, but I was expecting it to return all matches (like Student6 as well).

I've checked the documentation, but I couldn't find anything helpful for this use case. Would love to know if anyone has come across a workaround or better way to handle this.

Thanks in advance!

 

7 REPLIES 7

rajeshjanapati
Deputy Chef III
Deputy Chef III

Hi @Bhagya_pola,

As per my understanding and experience:

The data_table_lookup formula in Workato is designed to return only the first matching record, not all matches. This is expected behavior and is by design — it does not support retrieving multiple matching records directly.

Same like lookup tables also, with lookup formula, we are able to retrieve only one value, but there we can make use of the "search entries" action to retrieve multiple values.

If your use case requires fetching all records that match a certain condition (e.g., all students who joined the "Python" course), then you’ll need to use an alternative approach like:

by using SQL Transformations by Workato:

SELECT StudentName FROM StudentDetails WHERE CourseJoined = 'Python'

This will return all matching records, not just the first one.

Hello @rajeshjanapati ,

Thank you for your input!

My intention behind using the formula was to reduce task consumption and minimize the number of steps in the recipe. Currently, I'm using the Search records action with filter criteria from the data table, and I was hoping to replace that with a formula-based approach.

Unfortunately, it doesn't seem to achieve the desired result in this case.
Thanks again for your response!

Yes, to reduce the number of steps and tasks, instead of using Search Records, I would recommend using SQL Transformations by Workato application ( with in the query you can pass the conditions as you mentioned in search records action). With this approach, you can query data tables directly within the step. It consumes only one task, and the output can be stored as a file in FileStorage — all within a single task execution.

Regarding the data_table_lookup formula — by default, it's designed to return only the first matching record. I'm not exactly sure why it's built this way, but it might be intended for quick condition checks, similar to how ternary operations work in programming.

Yes, we can go with SQL transformations as well, but I don’t need that for my use case.

I’m using a scheduler (data table polling won’t work for my scenario), and within that, I’m using Search records as the initial step. So I was looking to set up a trigger condition using the data_table_lookup formula instead.