Solved

Livecycle - Display field as percentage with one decimal place

Posted on 2009-07-12
11
2,142 Views
Last Modified: 2012-06-22
How do I change the display parameters of a calculated field which displays the results as a percentage which will add one decimal place to the resulting percentage number.

All works except that the field display of percentage does not show a single decimal place.

I have changed the field from Numeric to Decimal with appropriate trailing digits, but, the field still only shows the whole number percentage.

Example: 0.548 as a field value displays 55% but I want it to show 54.8%
0
Comment
Question by:Lucrecious
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24840078
Try this - util.printf("%.2f", calculatedFieldValue);
0
 
LVL 1

Author Comment

by:Lucrecious
ID: 24840964
I already have the following javascript running in this field:

if (xfa.resolveNode("Total-Event-Sales-Target.Total-Event-Sales-Target-Sunday").rawValue != 0) {
(xfa.resolveNode("Total-Event-Sales-Actual.Total-Event-Sales-Actual-Sunday").rawValue - xfa.resolveNode("Total-Event-Sales-Target.Total-Event-Sales-Target-Sunday").rawValue) / xfa.resolveNode("Total-Event-Sales-Target.Total-Event-Sales-Target-Sunday").rawValue;
} else {
    // Set field to blank (or whatever else you would want) here

}

The display pattern is set to num.percent{}.

How do I incorporate your script above within the calculation set in this field?

0
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24841015
Store the rawValue in a variable and then format it using util.printf("%.1f", rawValue);
0
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 
LVL 1

Author Comment

by:Lucrecious
ID: 24841076
Can you provide details as to how the javascript calculation can be stored as a variable?

If you can paste the completed code into a response I will use the full 750 points on my account for the solution.

0
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24842327

var fld1 = 0;
if (xfa.resolveNode("Total-Event-Sales-Target.Total-Event-Sales-Target-Sunday").rawValue != 0) {
fld1 = (xfa.resolveNode("Total-Event-Sales-Actual.Total-Event-Sales-Actual-Sunday").rawValue - xfa.resolveNode("Total-Event-Sales-Target.Total-Event-Sales-Target-Sunday").rawValue) / xfa.resolveNode("Total-Event-Sales-Target.Total-Event-Sales-Target-Sunday").rawValue;

util.printf("%.1f", fld1);

} else {
    // Set field to blank (or whatever else you would want) here

}
0
 
LVL 1

Author Comment

by:Lucrecious
ID: 24842529
Almost there.

Remember that percentage fields are formatted as follows:
.18 as a value translates to 18%
.183 as a value translates to 18.3%

therefore, I changed the:
util.printf("%.1f", fld1);

to:
util.printf("%.3f", fld1);

however, without the Display pattern set as num.percent{}

I get the value of: 0.183

when the Display Pattern for the field is set to num.percent{}

I still get the value showing as: 18%

with no decimal place.

I would like the code to show the proper field display without using the Display Pattern.

Is the code able to show the display correctly?
0
 
LVL 1

Author Comment

by:Lucrecious
ID: 24842623
Acutally, Mohan the field calculates the decimal value with the script I currently have for the correct number of decimal places. When num.percent() is turned off as a Display Pattern the calculated value is absolutely correct. What I need is that the Display Pattern is able to show the percent value with once decimal place. Therefore, is it possible to include code within the num.percent() display pattern to allow for once decimal place? Does num.percent(%.3f) or some other variant make sense?

0
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24842625
Ok, remove Display pattern and modify the printf statement like this

util.printf('%.1f%',(i*100));
0
 
LVL 15

Accepted Solution

by:
mohan_sekar earned 500 total points
ID: 24842631
0
 
LVL 1

Author Comment

by:Lucrecious
ID: 24842663
Thanks Mohan, that was an answer to my question on their forums which I failed to check.
You get the points. It works perfectly. Thank you for all your efforts.
0
 
LVL 1

Author Closing Comment

by:Lucrecious
ID: 31602609
Mohan rocks!!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is in response to a question here (http://www.experts-exchange.com/Other/URLs/Q_28283850.html) at Experts Exchange. The Original Poster has a scanned signature and wants to make the background transparent so that the signature may be pl…
*Adobe Acrobat 9 was used for this article.  Particular steps may vary depending on software versions. Adobe Acrobat has many, many variables that my be utilized to customize your forms for clarity and ease of use. The Form Editing Tool will be y…
In this second video of the Xpdf series, we discuss and demonstrate the PDFimages utility, which, in a single command, is able to extract all the images from a PDF file and save each one in a separate image file (PBM, PPM, or JPG). Download and inst…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question