?
Solved

Livecycle - Display field as percentage with one decimal place

Posted on 2009-07-12
11
Medium Priority
?
2,197 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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 2000 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

In a previous article published here at Experts Exchange, Signature Image with Transparent Background (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_12380-Signature-Image-with-Transparent-Background.html), I explained how to cre…
*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…
Sometimes we receive PDF files that are in the wrong orientation. They may be sideways or even upside down. This most commonly happens with scanned or faxed documents. It is possible to rotate the view of these PDFs with the free Adobe Reader produc…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Suggested Courses
Course of the Month10 days, 4 hours left to enroll

762 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