How to filter "Value Entry" with Multiple criteria

kirkostas
Member Posts: 127
I want to filter "Value Entry" table on "Source No." and "Item No." fields using multiple criteria. To be more specific I have 1 table for the Customer and 1 table for the Item and I want to collect X Customer and X Items and use them to filter the "Value Entry" table.
The result will be something like this:
To be more specific this is the T-SQL script for the above example:
"Select * from [Value Entry] where ([Source No.]='A1' or [Source No.]='B1' or [Source No.]='C5' or [Source No.]='G4' or [Source No.]='S2') and ([Item No.]='01' or [Item No.]='02' or [Item No.]='04' or [Item No.]='07' or [Item No.]='09')"
The problem is that I don't know where to keep each Customer or Item value to build such a big string. I need something that I can store more than 5.000 "Source No." or "Item No." values and then apply them to "Value Entry" as I described above.
The result will be something like this:
"Value Entry".SETRANGE("Source No.",'A1|B1|C5|G4|S2'); "Value Entry".SETRANGE("Item No.",'01|02|04|07|09');
To be more specific this is the T-SQL script for the above example:
"Select * from [Value Entry] where ([Source No.]='A1' or [Source No.]='B1' or [Source No.]='C5' or [Source No.]='G4' or [Source No.]='S2') and ([Item No.]='01' or [Item No.]='02' or [Item No.]='04' or [Item No.]='07' or [Item No.]='09')"
The problem is that I don't know where to keep each Customer or Item value to build such a big string. I need something that I can store more than 5.000 "Source No." or "Item No." values and then apply them to "Value Entry" as I described above.
kirkostas™
0
Comments
-
Use a textBoxes with source Expression, say SourceNoValueString and another one say ItemNoValueString
SourceNoValueString := 'A1|B1|C5|G4|S2'; ItemNoValueString := '01|02|04|07|09'
"Value Entry".SETFILTER("Source No.",SourceNoValueString); "Value Entry".SETFILTER("Item No.",ItemNoValueString);
where the filtering is ot be done.... It is a report or form..??Sandeep Prajapati
Technical Consultant, MS Dynamics NAV0 -
Try with
WHERE ("Source No." IN ('A1','B1','C5','G4','S2')) AND ("Item No." IN ('01','02','04','07','09'))
For the smaller lists.
In case you need more values, you can try to join the tables and filter on those.
Otherwise, you will need to run the SELECT multiple times, (once for each item or each customer without a filter on the other field) and then test each record if you need it.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
[Topic moved from Navision forum to SQL General forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
It is a report.
And my problem is that I have so many criteria to filter with, that I don't know what variable to use. What will you do if you have to filter value entry table with 5.000 Item No. and 5.000 Source No. at the same time?
Where will you store the values to be able to build such a filter in value entry?
Is there any function in navision which not overwrite the previous filter?
for example:customer.findset; repeat valueentry.setrange("source no.",customer."no."); until customer.netx=0;
at the end i want to have value entry filtered with X customer no.
this will always overwrite the previous filter but i am asking you is there any way to do this?kirkostas™0 -
I doubt you will get a got solution using this approach. I think you should try to look closer at the actual data in the database. If you filter ends up to include 90% of all records you could do it a lot simpler. Simply begin the OnAfterGetRecord trigger with this:
IF NOT IsWithinFilter("Value Entry") THEN
CurrReport.SKIP;
Then write a simple C/AL function to test if the found Value Entry is within whatever filter you wish.
But if your solution is expected to only find 0.01% Value Entries it might not be the best solution. I guess you can set some filters on the Item and Customer tables to get the exact Items and Customer. Then I would estimate which of the filters (Customer or Item) that would result in the least Value Entries. Then I would loop through that table and find all related Value Entries and put them in a temporary value entry variable. Secondly I would go through the relevant records in the other table and search in the temporary table. All found records should then be put in a second temporary table. Finally should you report simple traverse through the second temporary table which holds the resulting dataset.
If neither of these solutions seems ok, then please describe the expected no. of records in the involved tables - both within the filter and outside the filter.Regards
Peter0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions