Query Design in NAV 2015 - Filter Date Syntax
Normajm
Member Posts: 82
We are new to NAV 2015 and query building. I built a simple query on the sales invoice header table. We want to see all orders posted this month grouped by salesperson. One of the fields selected is the Posting_Date field. I need to filter this field starting with the first day of the current month. I don't see an option to do that on the column filter. The option for C/AL Globals is greyed out.
So I tried the following code in the OnBeforeOpen () level: SETFILTER(Posting_Date, >=CALCDATE('CM-1M+1D', Today));
The code fails with "A value or expression was expected". What am I missing? Is there a better way to handle this?
Thank you
So I tried the following code in the OnBeforeOpen () level: SETFILTER(Posting_Date, >=CALCDATE('CM-1M+1D', Today));
The code fails with "A value or expression was expected". What am I missing? Is there a better way to handle this?
Thank you
0
Comments
-
you are mossing %1 in SETFILTER
https://msdn.microsoft.com/en-us/library/dd354919.aspx0 -
1) Wrong SETFILTER syntax...
SETFITLER(<field name>,'filter string',parameters...)
2) When using CALCDATE do not forget to use <> around your fixed values, else you are not multi-language compatible....CALCDATE('<-CM>',TODAY)0 -
Thank you for the help...changed the code to read as follows:
SETFILTER("Posting_Date", %1, >=CALCDATE('<CM-1M+1D>',TODAY));
Now I'm getting a syntax error. The MSN sample shows a Record.SetFilter syntax, but because this is a query, I'm not clear on how to put the record part in. When I look at the list, the first value is CurrQuery. The value for the DataItem, which is the sales invoice line, isn't listed.
0 -
Anyone interested in using NAV queries should look at our ReportPath product as an output mechanism. The product does a lot more than this, but here is a link to the page showing how it enables query output to be exposed through the NAV user interface easily: dynamicspath.com/products/reportpath/nav-query-output/.
The best part...we've made the add-on ABSOLUTELY FREE for all NAV 2015+ users until January 31, 2016. Contact info is on the website if you're interested.
I'll reply to your filter issue separately below.Rob Hansen
http://www.epimatic.com-1 -
Try:
SETFILTER("Posting Date", '>=%1', CALCDATE('<CM-1M+1D>',TODAY));
(You may want to use WORKDATE rather than TODAY depending on how you want to support dates)
Rob Hansen
http://www.epimatic.com0 -
Thank you Rob. That worked as planned, now I see how the syntax works. I am reaching out regarding ReportPath as well.0
-
Glad to help Normajm. You can email me at rob@dynamicspath.com for more info on ReportPath. It really is free until the end of January...not a crippled version and no upsells or anything. We think every NAV install should have it!Rob Hansen
http://www.epimatic.com0 -
Your CalcFormula does not work in all cases. Try what you get on e.g. Feb., 28 or June, 30.
The correct formula for what you stated you want is'<-CM>'
<Cx> is the same as <+Cx> and gives you the last day in the period x. <-Cx> gives you the first day of the period.
And concerning the SETFILTER, always remember: The filter expression with all the operators goes to the second parameter. It's type is a string, so use quotes if you use a literal. The values to use in your filter expression follow beginning from the third parameter.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
- 322 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


