Filter on Customer "Salesperson Code" - giving wrong results.

jonesks
Member Posts: 29
Hi
I have
Customer.SETRANGE("Salesperson Code",'1','2');
to pick up only those customers with a salesperson code of 1 or 2 - when I run the report it gives me numbers 1 2 and 11?
What am I missing?
Thanks
I have
Customer.SETRANGE("Salesperson Code",'1','2');
to pick up only those customers with a salesperson code of 1 or 2 - when I run the report it gives me numbers 1 2 and 11?
What am I missing?
Thanks
0
Best Answer
-
My bad, I misread your post somehow. You have to combine the two conditions you want to filter into a single filter string ('<%1&<>%2'´).5
Answers
-
customer.setfilter("Salesperson Code",'%1|%2','1','2');
Your code doesn't work because you filter from 1 to 2, and with the sorting of your DB the salesperson records look like this:1 11 2 21 22 . .
0 -
I understand the logic but now it is only showing number 10
-
In this case you are using the wrong filter.
The filter your using means set a filter on the "Salesperson Code" from '1' until '2'.
And because the "Salesperson Code"-field is datatype CODE everything starting with '1' is also in the filter.
The filter you can use is:
Customer.SETFILTER( "Salesperson Code",'%1|%2','1','2');0 -
Ok - Now I need to change it to filter only salesperson code 1 - 8. Any clues gratefully received!0
-
Ony 1 and 8 :
Customer.SETFILTER( "Salesperson Code",'%1|%2','1','8');0 -
Sorry - I meant between 1 and 8 as in 1,2,3,4,5,6,7,8 Thanks0
-
You can construct filters using the following operators.
Operator Description
.. Range
& And
| Or
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
<> Different from
* Forms a part of value
@ Case-insensitive
0 -
I keep trying but struggle with the correct result. I have tried 1..8 but it keeps picking up 11.
have tried
Customer.SETFILTER("Salesperson Code",'%1..%8','1','8'); which only gives me the first page!
I am guessing I am missing something really silly, but I have only been working with NAV for a month!
0 -
I think this is what you are looking for...
Customer.SETFILTER( "Salesperson Code",'%1..%2','1','8');0 -
Hi Nick - Tried that and it is still picking up those with a code of 11 - not sure why.0
-
can you try
Customer.SETRANGE("Salesperson Code", '1', '8');
Alternatively you could just use..Customer.SETFILTER( "Salesperson Code", '<=%1', '8');
0 -
Both of those pick up code 110
-
%1 = first parameter
%2 = second parameter
Now you used %8 and that is the eightst parameter. Only you never used a 8st parameter in your statement.
Customer.SETFILTER( "Salesperson Code",'%1|%2','1','8');
Translation:
Set a filter on the customer-tabel ( Customer.SETFILTER)
on the field "Salesperson Code" ( "Salesperson Code" )
Use as filtervalue parameter 1 OR parameter 2 ( ,'%1|%2' )
use for the first parameter the value '1' ( ,'1' )
use for the second parameter the value '8' ( ,'8')
0 -
I think it is because "1" appears in the code for "11"0
-
Try to understand what I wrote about sorting, then you will know why none of the suggestions will work.0
-
Customer.SETFILTER( "Salesperson Code", '<=8', '<>11'); tried this as well - which to me logically should work.
Smaller or equal to 8 and not 11.0 -
AK - what you wrote is making sense to me, 1,11, 2 ,22 etc. but for the life of me I cannot see a way of doing it other than to select it based on 1 - 8 and then exclude 11?0
-
Smaller 8 includes 11. Look at the sorting, I don't know what else to say exept giving you the solution. But that way it wouldn't klick, right?0
-
I see that 11 is smaller than 8 and I understand that, that is why I went for <=8 but <>11. Would I have to do this in two separate stages?
0 -
Ok, so my next theory is SETFILTER <=8 then use an if statement ? if = 11 then CurrReport.SKIP? Am I on the right lines?0
-
My bad, I misread your post somehow. You have to combine the two conditions you want to filter into a single filter string ('<%1&<>%2'´).5
-
Thanks AK - it's been a bit of a curve but one I am sure is worth doing!
0 -
Just wanted to say thanks everyone - my logic was right but I was trying to put the > or <> in the wrong place rather than setting parameters! As I said very new to this but finding the forums really helpful for learning0
-
you can also try
SETFILTER('?&%1..%2', '1', '8');
which translates to 'give me all codes exactly one character long, and between '1' and '8' inclusive.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Thanks, I managed to get the correct Syntax for codes 1-8 exclude 11 which covers what i needed.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