web
You’re offline. This is a read only version of the page.
close
Skip to main content
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.
I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    236,012 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
    236,012 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 825 User Group Leader

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 763 Super User 2025 Season 2

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 601

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans