Setting filt. on multiple fields and sowing the joint result

emkpro
Member Posts: 47
I try to make a filter which shows the result of
rec.Setfilter(Field1,Value1)
rec.Setfilter(Field2,Value2)
and show the sum of all filtered records
rec.Setfilter(Field1,Value1)
rec.Setfilter(Field2,Value2)
and show the sum of all filtered records
//EMK\\
0
Comments
-
Hi,
What result do you want?
If you just want to know the number of records left after you have applied your filters you use rec.COUNT. If you want to sum a field from the remaining records you will need to loop through them add keep a running total.
Example:
rec.Setfilter(Field1,Value1)
rec.Setfilter(Field2,Value2)
total = 0;
REPEAT
total += rec.FieldX;
UNTIL rec.NEXT = 0;
Does this help?0 -
No, what I want is a list of records which are "created by" "x" OR "modified by" "y". Created by and Modified by are two different fields of the same record.//EMK\\0
-
You cannot use OR between fields... there is always AND between filters on fields... you must do it in two steps...0
-
May be something like that? It shows list of rec where Field1=Value1 OR Field2=Value2.
rec.Setfilter(Field1,Value1) IF rec.FIND('-') THEN REPEAT rec.MARK(TRUE); UNTIL rec.NEXT = 0; rec.SETRANGE(Field1); rec.Setfilter(Field2,Value2) IF rec.FIND('-') THEN REPEAT rec.MARK(TRUE); UNTIL rec.NEXT = 0; rec.SETRANGE(Field2); rec.MARKEDONLY(TRUE);
0 -
That seems ok.
Something bothers me though: why rec.Setfilter(Field1,Value1) and then rec.SETRANGE(Field1); is it necessary ?
:oops: i realized now it releases the first filter thanks..randrews wrote:May be something like that? It shows list of rec where Field1=Value1 OR Field2=Value2.rec.Setfilter(Field1,Value1) IF rec.FIND('-') THEN REPEAT rec.MARK(TRUE); UNTIL rec.NEXT = 0; rec.SETRANGE(Field1); rec.Setfilter(Field2,Value2) IF rec.FIND('-') THEN REPEAT rec.MARK(TRUE); UNTIL rec.NEXT = 0; rec.SETRANGE(Field2); rec.MARKEDONLY(TRUE);
//EMK\\0
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