<turbo-stream action="update" target="wiki_card"><template>
<h1>Filtering with Dynamics NAV SQL</h1>
<p>Filtering with MS Dynamics NAV uses NAV's native filter syntax, which is similar to SQL but with some NAV-specific conventions. NAV filters support wildcards, ranges, and logical operators to create flexible query conditions.<br><br>Filter Syntax Rules</p><ul><li>NAV filters are <strong>case-insensitive</strong> for text comparisons</li><li>Use single quotes for text values containing spaces or special characters</li><li><strong>Field names with underscores, spaces, or special characters must be enclosed in square brackets </strong><strong><code>[Field_Name]</code></strong><strong> or double quotes </strong><strong><code>"Field_Name"</code></strong></li><li>Multiple filter criteria can be combined using <code>|</code> (OR) and <code>&amp;</code> (AND) operators</li><li>Date and time values should be formatted according to your NAV region settings</li></ul><h2>Examples:</h2><h3>Basic Text Filtering</h3><p></p><table class="table table-bordered"><thead><tr><td>Field Name</td><td>Filter</td></tr></thead><tbody><tr><td>No_</td><td>[No_] = '1000'</td></tr><tr><td>Name</td><td>Name = 'CRONUS International Ltd.'</td></tr><tr><td>No_</td><td>"No_" = '1000'</td></tr><tr><td>Order Status Text</td><td>[Order Status Text] = 'Released'</td></tr><tr><td>Order Status Text</td><td>"Order Status Text" = 'Released'</td></tr><tr><td>Description</td><td>Description = '<em>BICYCLE</em>'</td></tr><tr><td>No_</td><td>[No_] = '1000*'</td></tr><tr><td>External_Document_No_</td><td>[External_Document_No_] = ''</td></tr><tr><td>Item No_</td><td>"Item No_" != ''</td></tr><tr><td>Amount</td><td>Amount &gt; 1000</td></tr><tr><td>Posting_Date</td><td>[Posting_Date] = '01-01-2024..31-12-2024'</td></tr><tr><td>Document Date</td><td>[Document Date] &gt; '2025-05-01'</td></tr><tr><td>Location_Code</td><td>[Location_Code] = 'BLUE'|'RED'</td></tr><tr><td>Document_Type</td><td>[Document_Type] = 'Order'|'Invoice'</td></tr><tr><td>Base Unit of Measure</td><td>[Base Unit of Measure] IN ('001','002','003','005','007','008','010','050','100','120','200','MM')</td></tr><tr><td>No_</td><td>[No_] NOT IN ('','EP-00001744','1000001')</td></tr><tr><td>Document Type</td><td>[Document Type] = 0</td></tr><tr><td>Order Status Text</td><td>"Order Status Text" != 'Open' AND "Order Status Text" != ''</td></tr><tr><td>Document No_</td><td>[Document No_] IN (SELECT No_ from [%%DATABASE%].[dbo].[%%COMPNAME%$Sales Header] WHERE [Document Date]&gt;='2025-05-01' AND [Sell-to Customer No_] NOT IN ('','1005317','1005095','1006618','1001321'))</td></tr></tbody></table><p></p><h2>Important Notes:</h2><ul><li><strong>Field Names with Underscores or Spaces</strong>: Always use square brackets <code>[Field_Name]</code> or double quotes <code>"Field_Name"</code> when the field name contains underscores, spaces, or special characters.</li><li><strong>Both syntaxes are valid</strong>: <code>[Field Name]</code> and <code>"Field Name"</code> work identically - choose whichever you prefer.</li><li><strong>Option Fields</strong>: NAV option fields (like Document Type) can be filtered using their numeric values (0, 1, 2, etc.).</li><li><strong>SQL Subqueries</strong>: Advanced filtering supports SQL SELECT statements with Rapidi placeholders <code>%%DATABASE%%</code> and <code>%%COMPNAME%%</code>.</li><li><strong>FlowFields</strong>: Some NAV fields are FlowFields (calculated fields) and may have limitations on filtering.</li><li><strong>Performance</strong>: Complex filters with wildcards or multiple OR conditions can impact performance on large datasets.</li><li><strong>Table Relationships</strong>: When filtering on related tables, ensure the relationship is properly defined in your database.&nbsp;</li></ul><h2>Troubleshooting Tips:</h2><ul><li>If a filter isn't working as expected, verify the exact field name by checking the NAV table metadata.</li><li>Test complex filters directly in NAV using the filter pane to confirm syntax.</li><li>Remember that NAV treats empty strings and null values differently than Salesforce.</li><li>Check regional settings if date filters are not working correctly.</li><li><strong>If you get syntax errors, ensure field names with underscores or spaces are properly enclosed in square brackets or double quotes.</strong></li><li>Both <code>&lt;&gt;</code> and <code>!=</code> operators work for "not equal" comparisons.</li><li>Use <code>&amp;</code> or <code>AND</code> to combine multiple conditions on the same field.</li><li>When using SQL subqueries, ensure proper table naming with company name suffix (e.g., <code>[%%COMPNAME%$Sales Header]</code>).</li><li><code>IN</code> and <code>NOT IN</code> operators are useful for filtering against multiple specific values efficiently.</li></ul>
</template></turbo-stream>

<turbo-stream action="replace" target="meta_description"><template><meta content='Filtering with Dynamics NAV SQL' id='meta_description' name='description'></template></turbo-stream>
<turbo-stream action="replace" target="meta_keywords"><template><meta content='Filtering with NAV SQL add filters on transfers SQL operators' id='meta_keywords' name='keywords'></template></turbo-stream>
<turbo-stream action="update" target="meta_title"><template>Filtering with Dynamics NAV SQL - MyRapidi Wiki</template></turbo-stream>
<turbo-stream action="prepend" target="flash"><template></template></turbo-stream>
