Capping math calculation at zero?

Hi guys
How do you cap a maths calc so that if it's capped at zero if the result was going to be negative? Is there a func?
Cheers

yourcalculatedvalue = Math.max(0,yourcalculatedvalue)

Similar Messages

  • About math calculation in form command

    i want to know  if  we can do math calculation in script form's command line?i try it by using define command ,but cann't get the result,i have to make sure if the command line have the function of math calculation?

    do ur calculations inside a subroutine and call ur subroutine in ur script.
    check this wiki on how to use subroutines inside scripts
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/profile/external%2bsubroutines%2bin%2bsap%2bscript

  • Percentage calculation and zero amount entries get dvision by zero error

    Hello, i am calculating the total of a field and then reporting the contributions of that line entry in percentage form but when a line has a zero amount i get an error of 'division by zero'.  I'll give some explamples below incase i'm not explaining very well.  If you replace the 225 under amount with 0 that is when i get the error.
    code sample..
    WhilePrintingRecords;
    numbervar n := {@Total Weight}% Sum ({@Total Weight}, {JSALES_REPORT.SOPNUMBE});
    data sample...
    Amount      % of total
    150             40%
    225             60%
    (375)

    Hi Rod.
    I'd recommend using and IF statement to deal with division by zero.  I'm not sure what you exactly want to do with records that have division 0 but I usually do the following to see which records are creating the div by zero errors and then decide how I want the values to be displayed after evaluating it.
    WhilePrintingRecords;
    if {whichever.field} = 0 then 9999999999  // this would be an indicator to me to take a look at this record
    else
    numbervar n := {@Total Weight}% Sum ({@Total Weight}, {JSALES_REPORT.SOPNUMBE}); // your original formula
    You can then change the 99999999 number to whichever number you think should be viable to answer your business question on items that are divided by 0.
    Hope this helps.

  • Help with math / calculations in RTF templates

    Greetings,
    I know that there are math capabilities in the templates... I've seen the code samples in the Core Components guide.
    What this doesn't tell you is WHERE these things would go in a template. And... that... is my question.
    We are just starting to use BIP in conjunction with JDE EnterpriseOne (8.12, tool set 8.97.12). For our first attempt we're creating our template over a new report.
    I have a template where I sum two different repeating values (through the normal BI Properties) and place these values in two separate cells in a table. I want to sum the two of these together for a "grand" total.
    I've seen the "examples" but they really aren't very helpful. The xsfo, etc. for doing addition is fine, but WHAT are the values to add and WHERE does the code go?
    If anyone has done something like this or has experience using the embedded code I would appreciate hearing from you.
    Thanks in advance

    I see what you are saying about the spaces... but it made no difference... still got the error.
    The XML file is too large and convoluted to be pasted here.
    With reqards to the following snippet:
    COLA = <?sum(current-group()/COLA)?>
    COLB = <?sum(current-group()/COLB)?>
    Summ== <?sum(current-group()/COLA) + sum(current-group()/COLB)?>
    Where does THIS code go?
    Here is the error detail:
    ConfFile: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\config\xdoconfig.xml
    Font Dir: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\fonts
    Run XDO Start
    Template: C:\Documents and Settings\jdenison\My Documents\BIP Templates\R5642001\R5642001_TEMPLsave.rtf
    RTFProcessor setLocale: en-us
    FOProcessor setData: C:\Documents and Settings\jdenison\My Documents\BIP Templates\R5642001\R5642001_RICE0001_D081029_T144059683.xml
    FOProcessor setLocale: en-us
    java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at oracle.apps.xdo.common.xml.XSLT10gR1.invokeProcessXSL(Unknown Source)
         at oracle.apps.xdo.common.xml.XSLT10gR1.transform(Unknown Source)
         at oracle.apps.xdo.common.xml.XSLT10gR1.transform(Unknown Source)
         at oracle.apps.xdo.common.xml.XSLTWrapper.transform(Unknown Source)
         at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(Unknown Source)
         at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(Unknown Source)
         at oracle.apps.xdo.template.FOProcessor.createFO(Unknown Source)
         at oracle.apps.xdo.template.FOProcessor.generate(Unknown Source)
         at RTF2PDF.runRTFto(RTF2PDF.java:629)
         at RTF2PDF.runXDO(RTF2PDF.java:439)
         at RTF2PDF.main(RTF2PDF.java:289)
    Caused by: oracle.xdo.parser.v2.XPathException: Extension function error: Method not found 'sum'
         at oracle.xdo.parser.v2.XSLStylesheet.flushErrors(XSLStylesheet.java:1534)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:521)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:489)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:271)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:155)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:192)
         ... 15 more

  • Math calculations in Acrobat 8 Pro.

    I am using Acrobat 8 Pro on a windows machine running XP SP-3.
    I am building a form from a PDF document. I want to make some of the fields calculate totals from other fields... According to the Users manual (printer from the on-line documents), when I go to field properties, there should be a calculate tab which gives you the options to set the way you want the field to do calculations.
    THIS IS A TEXT FIELD.
    In the (Object)(Value) tab, I can select from a drop down box of 6 types of data; User Entered - Optional; User Entered - Recommended; User Entered - Required; Calculated - Read Only; Calculated - User Can Override; and Read Only. If (Calculate - Read Only) is sellected, I only have two radio buttons available. (Calculation Script), which gives me NO place to enter any script and, (Runtime Property) which gives me other options like page number viewer locale etc.
    I don't get what the manual says like; (Value Is Not Calculated) or (Value Is The) options. These, the way I understand it, should give more option to set up a calculation field...
    What am I doing wrong?
    By the way, the User manual I downloaded has reference to this on page 220.
    HELP

    Hi rdenichilo,
    Just out of curiosity, how many form fields are in the document? If the document is primarily text with just a signature field I'd recommend saving as RTF, but that will remove form fields. If you've got a lot of form fields we'll need a different idea
    Steve

  • Need help on complex math calculation in labview

    I need some help by being pointed in the right direction.  I have a piece of old lab equipment that I will be connecting to labview.  In order to send commands to the hardware, I have to calculate a checksum.  The checksum algorythm requires me to take alphanumeric characters, convert them to binary, perform binary addition, perform an Xor, mask certain digits, and convert the resultant binary string back to an ascii character.  Does labview have the capabilities to do this on it's own, or should I look at connecting to something like an external dll? 
    I have Visual Studio 2008 and some previous VB experience, so I think I could write a program that would do the calculation, but don't really know exactly what type of project (dll, etc.) is best.  Are there any specific settings for the dll so that labview can use it.  I see an example for C++ for Visual Studio 2005, but that is as close as I can get.  I only know VB, not C# or C++
    Can someone please point me in the right direction?
    Tron
    Solved!
    Go to Solution.

    You basically need some logical shifts and ANDs.
    Check version 2.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV
    Attachments:
    Checksum ver 2.vi ‏10 KB

  • Plug in for Math Calculation

    I am working in InDesign CS3. Need a plug in to change pricing in an 800pg catalog. For example need to increase all prices in a document by 15%. There is a Xtension for Quark called Math Grabber but it is not available for Indesign yet. Does anyone know of any plug in that can accomplish this in Indesign or even Acrobat?

    Hi Bob - There is no spreadsheet to link to, and to export the tables back to a spreadsheet, the only way I have been able to figure it out it to convert each table to text, one at a time, so that I can get the tab settings. There could be about 6 price table to a page. We are now manually doing the price change. We have just converted to InDesign from Quark thinking that if there is an xtension for quark, there must be one for InDesign. When we did this catalog last time, Math Grabber was available and comes to find out it is not available for Indesign.
    Thanks for your suggestion.

  • Simple math calculation in numbers

    Hi I'm trying to do a simple calculation of 46.66*2 in numbers and i get a red triangle saying syntax error. Any light on this as what is wrong.

    Hi Fuija,
    Happy to help, and strangely enough, I just got a fresh cup of coffee.
    Most issues are easier to solve when enough information is presented. Keep that in mind when you have another question.
    As to using , as the decimal separator, it's not a Mac thing. That's dependent on where you live and what regional settings you've made in System Preferences. If you'd normally write ten thousand four hundred twenty-three and five hundredths like this:
    10,423.05
    Then your regional settings for numbers should show 1,234.56
    and you should use a period as the decimal separator.
    If you'd normally write that number this way:
    10.423,05
    Then your regional settings for numbers should show 1.234,56
    and you should use a comma as the decimal separator.
    Pick whichever region is set to use the same separators as you would use when writing the number with pencil on paper.
    Regards,
    Barry

  • Math calculation problem! - Where is the help? ? ?

    I posted the message below hoping someone would be able to help - so far nothing!
    For sure there must be someone out there that can open the designer, create three numeric boxes, set the objects to be time oriented only, and the last box having the appropriate Java script or FormCalc script to have it show the difference in time.
    The script I show below works just great - accept as noted. WHY? What modifications do I need to make to have it work 100% of the time?
    <<<< below is the orginal posting on the forum >>>>>>>>>>
    The following Java script is entered in as the "total time" calculation formula
    "this.rawValue = endingTime.rawValue - beginningTime.rawValue" however when the following times are inserted the calculation accuracy fails.
    beginning time: 1430
    ending time: 1700
    the total time becomes 2:70 rather than 2:30.
    The reason seems to be the time format in PM mode is reading as a numeric formula rather than a time formula. Therefore, the subtraction is standard borrowing and carrying (1700 becomes 1600 + 100 + 0) rather than time (1700 becomes 1600 + 60).
    Does anyone have a solution?
    I have also tried resolving the issue using "FormCalc" but with no success
    Please help!
    thanks,
    tom

    the accuracy is tottaly correct 1700 -1430 is 270 it is that simple however what your trying to do is subtract the milliseconds of one time from another and convert it back into that many milliseconds divided up into hours and minutes. So calm down and get the formcal refrence manual to help it is poorly written but it is a starting point.
    I think you want to do this set both of the fields startDate and EndDate to time/date fields this way you can lock the way information is entered set the display validation and binding patteren to HH:MM then set the binding tab to time from here your final box can be a text field or a date field doesnt matter so much then the easiest way to do this in Livecycle is to use form calc on the total time field
    set the script to formcalc and place it under the calculation event.
    if(startDate.isNull or endDate.isNull) \\ keep calculation clean
    then
    $ = 1 \\incase used with another calculation no errors
    else
    $=Time2Num(startDate.formattedValue, "HH:MM")-Time2Num(endDate.formattedValue, "HH:MM")
    endif
    you may have to do some tweaking to get the number that comes out as the format you want but this should lead you down the right path the Time2Num can be reversed using Num2Time also
    good luck

  • Simple Math Calculation is incorrect

    I have seen this topic here before but cant find it. When I
    do the following script it returns an incorrect value;
    var myNumber = 999.43
    trace(myNumber-999) //returns: 0.42999999999995
    So how can I retrieve the value .43? I suppose I can do this;
    var myNumber = 999.43
    var hundred = myNumber*100;
    var whole = hundred-99900;
    trace(whole*.01) // returns: .43
    But is there a better way? And why is it that Flash is
    calculating like this?

    the reason for the apparent error is because flash is
    performing arithmetic on a binary computer. within the limits of
    flash'es accuracy (16 digits),
    0.42999999999995 = .43
    to eliminate those errors, you can use integer arithmetic or
    the flash string methods. integer arithmetic is probably preferable
    if you're doing arithmetic operations.

  • Math calculation problems

    My Timeline of the Universe needs fixing. I have hobbled together something that works so-so, but the attached swf shows the flaws.
    Assistance much appreciated.

    If you explain the issue in more detail and provide the calculations that are not working you might get better results.  Most people are not going to spend time searching thru a file to try to see what is wrong.  I looked thru it briefly and the problem isn't obvious to me.

  • Auto ROP calculated with zero cosumption history

    Hi
    MRP type = VM - auto re-order point based on the consumption history. there is no consumption history, but after the first MP38 background job run, the ROP got calculated, I checked at MM02, the forecast was the ex post forecast value, I tried to do MP38 manually, it was terminated, and I tried to run forecast from MM02, forecasting view, got error message said there were no historical data.
    Question is how the ROP got calculated if I can't even run the forecast with both MP38 and MM02, manually.
    Care to share if you come across this before.
    Thanks

    Hi
    Strange error. But I need more information. If you don't see any consumption value in MM02 doesn't mean that there is no consumption. When this material was used? Look in to change history of that material. If period indicator in MRP-3 view is changed, all consumptions will vanish in MM02.Even forecast will not work. It doesn't mean that consumption is done in the past. Check table S033 in se11 for your material without specifying any period and see is there any consumption in past. And check was there any safety stock in present and past. Your problem may get solved. Write to me your findings
    Regards
    Antony

  • Math calculation with char

    i need alittle help with this:
    int x=10
    int y=5
    char c='+'
    how can i add the two numbers using the c operator???
    thnx

    diamantnir wrote:
    i need alittle help with this:
    int x=10
    int y=5
    char c='+'
    how can i add the two numbers using the c operator???
    thnx'c' isn't an operator; it's a char variable.
    if (c == '+') {
        return x + y;
    }~

  • Math Calculation - Dividing Different Aggregated Rule

    Is there a way to take a numeric value with an aggregated rule (Count) and divide the denominator value which has to have a aggregated rule (SUM)?
    Edited by: NOTW_TEK22 on Mar 6, 2013 7:38 AM
    Edited by: NOTW_TEK22 on Mar 6, 2013 7:39 AM

    I was able to resolve my problem with the below formula: I was using a custom field not derived from an object in the data hub and an object that was in the data hub in this syntax.
    CAST ("Revenue Metrics"."# of Open Opportunities" / "Revenue Metrics"."# of Opportunities" as float) * 100

  • Help with Match Calculations

    I have a simple form on a web page for associaiton members to
    order lapel pins. I want to provide a toal cost of the order but I
    can't for the life of me get anything to multiply the value in a
    text fiels by a constant number ($5.00). I found some Javascript on
    the internet but I couldn't get it to function either. I am using
    Dreamweaver 8 and cannot find any reference to simple math
    calculations. Imust be overlooking something as something so simple
    can't be that hard. Can someone provide me with some simple script
    or method of doing this?

    >I have a simple form on a web page for associaiton
    members to order lapel
    >pins.
    > I want to provide a toal cost of the order but I can't
    for the life of me
    > get
    > anything to multiply the value in a text fiels by a
    constant number
    > ($5.00).
    In ASP/VBSCRIPT:
    <%
    Dim varAmount
    varAmount = Request.Form("HowMany") * 5
    Response.Write FormatCurrency("varAmount")
    %>

Maybe you are looking for

  • HTTP Adapter Interconnect 10.1.2 problem

    Hello, Can someone explain me how to use Interconnect for sending xml-messages from a database to a webservice, and processing the answer? We tried the following: Install a database adapter Install a (sync) http adapter The common view is a procedure

  • Can anyone help me here i'm new here and with a lost and found ipod mini

    hi everyone i found an ipod mini second generation and i think in order for me to beable to use it i have to have the c.d that comes with it. i already dowloaded i tunes 7 and tried everything for i tunes to recognize it, my computer recognized it bu

  • Q: Parsing an IAK file in LabVIEW

    Hello, I am looking for a way to read the fieldpoint channel names in their real order (not sorted) _and_ their corresponding range settings from an IAK file. Hardware is a FP-1001 network module connected via RS485 and a handful of AI-110s and AO-21

  • User master

    Hi We send mail from maintenance notification to lotus notes. For this we need to maintain the emaid id in the user master. My question is whether we need to maintain some value in the field just below the email id. ie  "comm meth".. regards ramesh

  • Apple Newbie, Powerbook G4... help

    Hi, I have a quick question, I have a friend who is goin to sell me a G4 cheap, only thing is that it freezes up from time to time, he says just turn it off and back on. What could cause this typr of problem and how much would it cost? Thanks in adva