web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / oData query to filter ...
Power Automate
Unanswered

oData query to filter column by a list of values

(0) ShareShare
ReportReport
Posted on by 674

I have an SQL table with a list of Project IDs (23-029, 22-019, etc.). Due to large volume, I want to only pull records where Project ID matches a smaller list of these projects. So there may be 100 projects in the database, resulting in 6,000 total records, but I only need 3 or 4 of those projects. I want to do this directly in the SQL Get Rows action to limit the time required to pull the data from SQL to Power Automate (and to PowerApps).

How would I approach this? For example, I only want to pull records that match this list of projects: 22-019, 23-045, 22-123, 24-225.

oData does not seem to have an 'in list' or 'in' function. 

This list is variable with each run, and will be passed in by pulling from another data table in real time, so it cannot be hard-coded in advance.

Categories:
I have the same question (0)
  • DJ_Jamba Profile Picture
    2,837 Super User 2025 Season 2 on at

    Hi @Runner55552 

    You can't pass an array to an oData filter query.
    Instead, you create an array of projects, loop through that array and call the SQL Get Rows action passing a single project to filter on.

    Option 2. (Limit is 5000). Get up to 5000 rows and then you can use the Filter query action to filter those records by whatever is in your array.

    Option 3. Use the above technique but inside a Do Until loop where the Do Until will keep pulling batches of 5000 using the skip token oData.NextLink. When oData.NextLink is empty there's no more records to fetch. Then you can use the Filter query action to filter all of those records by whatever is in your projects array

  • 55552 Profile Picture
    674 on at

    Options 2 and 3 will not help me. The biggest time component/delay for PowerApps users is waiting 10 to 15 seconds for the full data set to be pulled in from an SQL database. So I need to do the filtering during the Get Rows action. If I used Option 1 to loop through the array one project at a time, would there be a way to keep appending the results so that I would have all the collected rows together? Maybe an array variable inside the loop that gets appended?

  • Verified answer
    DJ_Jamba Profile Picture
    2,837 Super User 2025 Season 2 on at

    Yes of course. 
    Initialise an array and then append to it when you find a match...

  • DJ_Jamba Profile Picture
    2,837 Super User 2025 Season 2 on at

    Glad it's sorted!

    P.S. @Runner55552 
    When you do get SQL results, you're going to use an Apply to each action to append the results to the array.
    Make sure you click on the 3 dots of the Apply to each action, enable concurrency and push it right up to the max (50). Results will be added to the array really, really fast.

     

    d(-_-)b   

  • 55552 Profile Picture
    674 on at

    One other thought. If I end up needing a loop to get rows for each individual project, I think that will make an API call to the SQL database with each loop. When I tracked this previously, each call to connect to the database took as much as a second or sometimes more. This could potentially end up taking the same amount of time as making a single call without the filtering. Of course, it is better to only get the data I need. I cannot think of any other method to do the query without looping and making a call to the database, though.

  • DJ_Jamba Profile Picture
    2,837 Super User 2025 Season 2 on at

    Absolutely correct.

    Sadly, I think this is by design. It's a subscription service after all...

    I can get 999 rows in one call using _api/$batch but I've only done it on a SP list and I think it's way overkill for what you're looking for

  • 55552 Profile Picture
    674 on at

    However, since you suggested the concurrency idea for the loops, if the concurrency is set to 50, and I only have 10 or 20 different projects to loop through, even if each loop makes an API call, the elapsed time should still be equivalent to a single call. I hope to test this today.

  • 55552 Profile Picture
    674 on at

    I have the loop set up that loops through the list of projects (only four right now, so loop repeats 4 times).  This all works well and the total time is only 2 seconds (longest of the 4 loops, larger amount of data). 

    Do you have an example flow where you loop through data like this and append to an array (or string variable)? Append to array caused an error, so I am using a string variable and appending the output of each GetRows action to that string variable. This gets all the data, but there are extra square brackets ([]) around each set of data. I just want a single combined array as output. I can probably do this with a couple of replace statements to get rid of the internal extra square brackets, but perhaps there is a simpler solution.

    Active Projects below contains the array of projects: ['Project1', 'Project2', etc.] and the variable is a string variable.

    Thanks!

    Runner55552_0-1713382987159.png

     

  • 55552 Profile Picture
    674 on at

    Although I agree with your solution, I ended up taking a different approach. I had trouble with the looping, due to my specific requirements to get a combined array of objects as the output from the SQL database. It was taking too many replace statements to insert/delete brackets, etc.

    I ended up totally bypassing the loop idea, and creating a concatenated oData query consisting of Project eq 'Project1' or Project eq 'Project2' or Project eq 'Project 3', etc.  I just looped through my input array which comes from PowerApps in the format of ["Project1", "Project2", etc.], and inserted "Project eq' and ' or ' as part of the concat statement. Then the combined statement goes in a Compose statement, and I just referenced that compose statement in the oData query in the Get Rows action. Tests have worked, but will do a full test from PowerApps soon. PowerApps calls the flow, then returns the results of the GetRows back to PowerApps with a Response action.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard