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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Two Properties filter condition by and condition

(0) ShareShare
ReportReport
Posted on by 85

I need to check two field filters condition by and condition in the Query Page.


Example

Sno Product  Cost  Qty
1  A 100 5
2 B 200 6
3 C 0 0
4 D 900 10

Filter by = (Cost != 0 and Qty != 0)

We want the result is

Sno Product  Cost  Qty
1  A 100 5
2 B 200 6
3 C 0 0
4 D 900 10

Remove to Sno - 3 item data

I have the same question (0)
  • Suggested answer
    Govinda Kumar Profile Picture
    2,304 Moderator on at

    Hi Thiran,

    You can either filter the query like this

    var
        MyQuery: Query "You Query Name";
    begin
        MyQuery.SetFilter(Quantity,<>,0);  
        MyQuery.Open;  
        while MyQuery.Read do  
        begin
        // populate the temp table
        end;   
        Myquery.Close; 
    end;

    or you can also add filters dynamically by using in Query Designer, as shown in the example on this Microsoft Learn page:

    query 50100 "Your Query Name"
    {
        QueryType = Normal;
    
        elements
        {
            dataitem(C; Customer)
            {
                column(Customer_Number; "No.")
                {
                }
    
                dataitem(SL; "Sales Line")
                {
                    DataItemLink = "Sell-to Customer No." = c."No.";
                    SqlJoinType = InnerJoin;
                    DataItemTableFilter = Quantity = filter(<> 0);
    
                    column(Qty; Quantity)
                    {
                    }
                }
            }
        }
    }

    learn.microsoft.com/.../devenv-query-filters

    I hope it helps

    Regards

  • Thiran Profile Picture
    85 on at

    I need to check two fields.. with and condition 

    example:

    if (Quantity not qual 0 and discount not qual 0) then show the data

  • Verified answer
    Govinda Kumar Profile Picture
    2,304 Moderator on at

    Hi Thiran,

    to do so you have to write it like this in the query filter

    var
        MyQuery: Query "You Query Name";
    begin
        MyQuery.SetFilter(Quantity,<>,0);
        MyQuery.SetFilter(Discount,<>,0); 
        MyQuery.Open;  
        while MyQuery.Read do  
        begin
        // populate the temp table
        end;   
        Myquery.Close; 
    end;

    And in Query Designer you can do it like this
    query 50100 "Your Query Name"
    {
        QueryType = Normal;
    
        elements
        {
            dataitem(C; Customer)
            {
                column(Customer_Number; "No.")
                {
                }
    
                dataitem(SL; "Sales Line")
                {
                    DataItemLink = "Sell-to Customer No." = c."No.";
                    SqlJoinType = InnerJoin;
                    DataItemTableFilter = Quantity = filter(<> 0), Discount = filter(<> 0);
    
                    column(Qty; Quantity)
                    {
                    }
                }
            }
        }
    }

    Hope it helps
    Regards

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,024 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 965 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 701 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans