how to display 4 decimals as a percentage?
johnsogj
Member Posts: 103
I am calculating a field in report to show the Margin for various items. The result is a 4 decimal number. however, I need it to be displayed as a percentage. ex. ".1234" should be "12.34%". how can I do this? here is my code to make the first calculation. I couldnt figure out how to use the FORMAT function to do this... any ideas?
Margin10 := (XPriceTable."Unit Price" - Item."Unit Cost")/ XPriceTable."Unit Price"
Margin10 := (XPriceTable."Unit Price" - Item."Unit Cost")/ XPriceTable."Unit Price"
0
Comments
-
from a pure math standpoint you would multiply the results by 100 to form a percentage...-MP0
-
makes perfect sense. it works. now I have
Margin10 := ((XPriceTable."Unit Price" - Item."Unit Cost")/ XPriceTable."Unit Price") * 100
but how do I tack on a percentage sign? I tried to just add + '%' at the end but it doesnt like the fact that I'm mixing decimals and text. I also tried to create a new variable as such:
Margin10B := Margin10 + '%'
but again, it doesnt like mixing decimals and text...
any ideas?0 -
Here is a bit of code from a report that assigns the decimal to a text variable and then adds the % sign to the text string: GPMSTRING is my text variable...
GP := InvoicedAmt - ReturnedAmt + CostAmt;
IF (InvoicedAmt - ReturnedAmt) = 0 THEN
GPM := 0
ELSE
GPM := ((GP / (InvoicedAmt - ReturnedAmt)) * 100);
IF STRLEN(FORMAT(ROUND(GPM,2))) > MAXSTRLEN(GPMString) THEN
GPMString := FORMAT(GPM,MAXSTRLEN(GPMString))
ELSE BEGIN
GPMString := FORMAT(ROUND(GPM));
j := STRPOS(GPMString,'.');
IF j = 0 THEN
GPMString := GPMString + '.00'
ELSE IF j = STRLEN(GPMString) - 1 THEN
GPMString := GPMString + '0';
GPMString := GPMString + '%';
END;-MP0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions