Use of functions in tables

imurphy
Member Posts: 308
I want to add a column to a table to calculate a percentage. As a test I added a column and set this as the source expression:
Quantity/"Qty. to Invoice (Base)"
The problem is when "Qty. to Invoice (Base)" is 0.
I've been digging through David Studebaker's book among other sources and cannot find any references to what you can put in source expressions.
I'd guess I want something like
if ( iserror(Quantity/"Qty. to Invoice (Base)"),
0,
Quantity/"Qty. to Invoice (Base)")
Anyone know what you can put into source expressions?
I'm also going to have to format the output as a percentage but I can't find documentation on the available options for the format property on a numeric field. Again - any pointers?
Ian
Quantity/"Qty. to Invoice (Base)"
The problem is when "Qty. to Invoice (Base)" is 0.
I've been digging through David Studebaker's book among other sources and cannot find any references to what you can put in source expressions.
I'd guess I want something like
if ( iserror(Quantity/"Qty. to Invoice (Base)"),
0,
Quantity/"Qty. to Invoice (Base)")
Anyone know what you can put into source expressions?
I'm also going to have to format the output as a percentage but I can't find documentation on the available options for the format property on a numeric field. Again - any pointers?
Ian
0
Comments
-
Create a function in the table (and NOT the form!) that receives a records as parameter and returns a decimal
Something like this:Function CalculatePercentage(recTheTable : record "The Table") OblnPercentage AS Decimal IF "Qty. to Invoice (Base)" = 0 THEN EXIT; EXIT(Quantity/"Qty. to Invoice (Base)" * 100);
In the sourceexpression, you can use that function asCalculatePercentage(rec)
Remark : you CANNOT filter on that field.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
I created a function in the form - why do you say to not do this?0
-
imurphy wrote:I created a function in the form - why do you say to not do this?
One of the reasons is that if you put it in the table, you can more easily use that code in other objects.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!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