Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to pass multiple values in an execute query to filter?

(1) ShareShare
ReportReport
Posted on by 202
Hi,
I have a table 1 with a field emp id. and example it has 3 values. 001, 002, 003.

I have a fast tab, with table 2 which as all emp ids updated. 

I need to write a query in table 2, where it can filter only 3 values from table 1 i,e 001, 002, 003. 
 
For example: I need to filter as is one of values.
  • Verified answer
    Martin Dráb Profile Picture
    234,484 Most Valuable Professional on at
    How to pass multiple values in an execute query to filter?
    Your code shows a single employee because you added a range for a single employee. My code would show three, because there are ranges for three values. To see more, you could simply add more ranges. You could iterate relevant (whatever it is) records in Table1 and add a range for each employee. That answers what you asked for, but what you really need may be something else.
     
    But if you want to show all Table2 records that have a related record in Table1, using query ranges is a bad approach. Use a join instead, probably an exist join.
  • RSX Profile Picture
    202 on at
    How to pass multiple values in an execute query to filter?

    Hi Martin,

    Yes, I understand how to add ranges. The examples I provided—001, 002, 003—were merely illustrative.

    My main concern is that "Table 1" could contain any number of employee IDs. I want "Table 2" to filter out all the employee IDs present in "Table 1."

    Currently, if I Override an execute query in Table 2 like this:

    this.query().dataSourceTable(tableNum(table2)).addRange(fieldNum(table2, empid)).value(queryValue(Table1.Empid));

    it only filters out a single employee ID from Table 1, rather than all relevant employee IDs.

    Could you please advise on how to achieve the desired filtering?

    Thank you!

  • Suggested answer
    Martin Dráb Profile Picture
    234,484 Most Valuable Professional on at
    How to pass multiple values in an execute query to filter?
    You talk about adding a writing a query in a table, but you likely mean adding ranges to a form query.
     
    If you know how to add a range for a single value, you're almost there. Just add two more ranges in the same way:
    QueryBuildDataSource myTableQbds = myTable_ds.queryBuildDataSource();
    
    myTableQbds.addRange(fieldNum(MyTable, MyField)).value(queryValue('001'));
    myTableQbds.addRange(fieldNum(MyTable, MyField)).value(queryValue('002'));
    myTableQbds.addRange(fieldNum(MyTable, MyField)).value(queryValue('003'));

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 565

#2
Martin Dráb Profile Picture

Martin Dráb 536 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 402 Super User 2025 Season 1

Product updates

Dynamics 365 release plans