Format percentage with leading sign

Does anyone know how to format a percentage so that the leading sign is always shown?
eg format .126 as +12.60%
and -.345 as -34.50%
Thanks.

Sorry, the above does not deal with +/- sign. For this you must use DecimalFormat and getxxxSuffix() and setxxxSuffix() methods.

Similar Messages

  • Numeric format with leading sign

    Hi,
    I am sending some data to external agency thru my info spoke extraction. They want the - sign leading the amount field, Eg I asm sending as 400- and they want -400. I am looking for any component type that supports this kind of format on currency filed. I am expecting this change to be done in the TARGET STRUCTURE, so I don't have to code it in my BADI to produce this format.
    Any ideas. It is URGENT.
    Thanks,
    Alex.

    Hi Alex,
       For this one, Function Module available in R/3. But that function module is not available in BW.
    But you can create it: Thia is the code.
    FUNCTION ZPUT_NEGATIVE_SIGN_FRONT.
    ""Local interface:
    *"  CHANGING
    *"     VALUE(VALUE)
      DATA: TEXT1(1) TYPE C.
      SEARCH VALUE FOR '-'.
      IF SY-SUBRC = 0 AND SY-FDPOS <> 0.
        SPLIT VALUE AT '-' INTO VALUE TEXT1.
        CONDENSE VALUE.
        CONCATENATE '-' VALUE INTO VALUE.
      ELSE.
        CONDENSE VALUE.
      ENDIF.
    ENDFUNCTION.
    Only specify parameters for Changing :
    Here "Value" .
    For your input : 100-, you will get outpt : -100.
    Hope it Helps
    Srini
    Message was edited by: Srini

  • How to create field with LEADING sign?

    I have a request to create an output file that has any negative signs in a leading position.  Example, value is 100.00- but we want it stored/displayed as -100.00.  Anyone know if there is a FM (could not find one), etc. that does this?  Thanks!

    I don't know of any FMs that will do what you want.
    There are, however, several ways of doing this using the WRITE command to transfer a number to a character field. This is all you really need, since you say you are filling a field of a structure you will be downloading to an external file.
    1) You can try the <b>USING EDIT MASK <mask></b> additions to <b>WRITE</b>.
    2) You can use <b>SHIFT <field> CIRCULAR RIGHT</b> to move any sign that exists to the beginning of a character field. This is all the formatting you need to give Excel a negative number it can parse. Other end user programs may require more work to remove the gap between the "-" and the digits of the number.
    I've found (2) to be a better approach. Good luck!

  • Format numbers with leading zeros

    Hi,
    Im returning the time as a string from a function like so
    return minutes + ":" + seconds + ":" + millisec;
    But I need each part to always display with two digits and
    show leading zeros.
    Can anyone tell me how
    Thanks

    Thanks NedWebs
    I have done this
    var minstring = minutes.toString();
    var secstring = seconds.toString();
    var millistring = millisec.toString();
    if( minutes < 10 )
    minstring = "0" + minstring;
    if( seconds < 10 )
    secstring = "0" + secstring;
    if( millisec < 10 )
    millistring = "0" + secstring;
    if( millisec < 100 )
    millistring = "0" + secstring;
    return minstring + ":" + secstring + ":" + millistring;
    Thought there must be a better way.
    But it works!

  • Ssrs format amount with dollar sign

    In an SSRS 2008 r2 report, I am trying to display a transaction amount in the report
    with dollar and cents amounts. I have tried to used the following:
    =Format(Fields!TransactionAmount.Value, "C")
    but I do not see value that look like the following:
    $25.00
    $166.89.
    I just see:
    25.00 or 166.89.
    I do not see the $ in the amount.
    Note: In a summary line I have code like
    =IIF(Fields!PaymentType.Value=
    "Ch", sum(cdec(Fields!TransactionAmount.Value)),0)
    Thus can you tell me what I can do so the dollar and cents amounts are displayed in the report?

    You dont need to use Format function for this
    you can achieve it by selecting the relevant symbol option in textbox properties as below for currency type
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Conditionnal Formating Data  with leading zeros

    Hi,
    I have a report which is displaying the name of CD's lile this:
    C2009-1
    C2008-257
    C2008-3456
    C2008-12984
    In the database, there is a column
    Type: C
    Year: 2008
    CDNum: 1
    How, when I'm displaying the report, it always return a 5 digits number, with zero before to have this output:
    C2009-00001
    C2008-00257
    C2008-03456
    C2008-12984
    thanks,
    Roseline
    Edited by: Roseline on Oct 1, 2009 8:58 PM
    Edited by: Roseline on 6 oct. 2009 08:50

    Thanks for your help.
    My boss ask me to show 4 digits if the year = 2008 or 2007 or 2006, etc
    and 5 digit if the year = 2009
    C2009-1
    C2008-257
    C2009-3456
    C2008-12984
    In the database, there is a column
    Type: C
    Year: 2008
    CDNum: 1
    SELECT type || year || '-' || LPAD(cdnum, 5, '0') *IF YEAR < 2009*
    FROM your_table
    or
    SELECT type || year || '-' || LPAD(cdnum, 5, '0') *IF YEAR = 2009*
    FROM your_tableSo basiccly, I need to insert an IF in my SQL statement, can I do that??
    thanks,
    ROseline
    Edited by: Roseline on 6 oct. 2009 08:45
    Edited by: Roseline on 6 oct. 2009 08:49

  • How do I do use the custom code and format for a percentage with 2 decimals in Report Builder 3.0?

    In Report Builder 3.0, I have the following custom code entered:
      Public Function SafeDivide(Numerator as String, Denominator as String) as String
    Try
    If Numerator = “” or Denominator = “” then
    Return “-“
    End if
    If Numerator = “-“ or Denominator = “-“ then
    Return “-“
    End If
    If CDbl(Numerator) =0 or CDbl(Denominator) = 0 then
    Return “-“
    End if
    If IsNothing(Numerator) or IsNothing(Denominator) then
    Return "-"
    End if
    Return Val( ( (CDbl(Numerator) / CDbl(Denominator) )*100 ) )
    Catch
    Return "-"
    End Try
    End Function
    I call the custom code in the cell with the following equation:
      =Code.SafeDivide(sum(Fields!TY_UNITS.Value)-sum(Fields!LY_UNITS.Value),sum(Fields!LY_UNITS.Value))
    I have the format for the cell set to 0.00%, but it’s not being followed.
    I want the result to be formatted as a Percentage, but instead I get values like: 
    -78.9473684210
    80
    300
    -100
    I have the format for the cell set to 0.00%, but it’s not being followed.
    How do I do use the custom code and format for a percentage with 2 decimals?

    Hi AngP,
    After testing the issue in my local environment, I can reproduce it. Based on my research, I find this issue is caused by the type of Units_VAR_Percentage cell is string, while the type of CDbl(Parameters!Var_Threshold.Value) is double, so they cannot be
    compared.
    To fix this issue, we can add a hidden column (Textbox91) next to the Units_VAR_Percentage column, and type =(sum(Fields!TY_UNITS.Value)-sum(Fields!LY_UNITS.Value)) /sum(Fields!LY_UNITS.Value) as the expression. Then use the expression below to control the
    BackgroundColor:
    =iif(iif(reportitems!Units_VAR_Percentage.Value=CStr(format(reportitems!Textbox91.Value,"0.00%")),reportitems!Textbox91.Value,0)>CDbl(Parameters!Var_Threshold.Value),"Yellow","PaleTurquoise")
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How can I format a number with leading zeros?

    I need to convert an int to occupy exactly 3 positions in a StringBuffer... I need the space in the StringBuffer to be filled with leading zeros where appropriate. Can anyone show me how to do this correctly please ?
    At the moment I am using a pretty dumb workaround to fill the target with "000" first and then parse the int into either 1 2 or 3 positions depending on its value ... it works, but there must be a more correct way to do this ...
    Thanks in advance ...

    Have you had a look at the class java.text.DecimalFormat? It does exactly what you want... example:
    StringBuffer sb = new StringBuffer();
    DecimalFormat format = new DecimalFormat("000");
    format.format(2, sb, new FieldPosition(0));
    System.out.println(sb);
    prints out the string 002.

  • Display numbers formatted with leading zeros or spaces.

    There are some cases where you might need to display numbers with leading zeros or leading spaces, or trailing zeros.  I experimented with several methods and came up with some examples.  This is a Console application, but the results can just
    as well be output to a listbox in a Windows form.
    Sub Main()
    Dim snum As String, inum As Integer = 56
    snum = inum.ToString()
    Console.WriteLine(snum & vbTab & " ToString()")
    snum = inum.ToString("D4") 'adds leading zeros
    Console.WriteLine(snum & vbTab & " ToString(""D4"")")
    snum = inum.ToString("F4") '4 decimal places with trailing zeros
    Console.WriteLine(snum & vbTab & " ToString(""F4"")")
    Console.WriteLine()
    snum = String.Format("{0,4}", inum) 'leading spaces
    Console.WriteLine(snum & vbTab & " Format{0,4}")
    snum = String.Format("{0:D4}", inum) 'leading zeros
    Console.WriteLine(snum & vbTab & " Format{0:D4}")
    snum = String.Format("{0:F4}", inum) '4 decimal places with trailing zeros
    Console.WriteLine(snum & vbTab & " Format{0:F4}")
    Console.WriteLine()
    snum = inum.ToString().PadLeft(4, "0"c) 'leading zeros
    Console.WriteLine(snum & vbTab & " PadLeft(4, ""0""c)")
    snum = inum.ToString().PadLeft(4, " "c) 'leading spaces
    Console.WriteLine(snum & vbTab & " PadLeft(4, "" ""c)")
    Console.ReadLine() Console.Clear()
            For x As Integer = 1 To 20
                snum = x.ToString("D4")
                Console.WriteLine(snum)
            Next x
            Console.ReadLine()
    End Sub
    Solitaire

    I would add that many of these methods also work with numeric types that are not integers.
    Note that the "D4" format string doesn't work for non-integral types (such as Double and Decimal), and the "F4" format string doesn't pad with trailing zeros, it rounds to 4 decimal places (which can lose information). PadLeft works with
    the entire string, it isn't aware of the decimal point.

  • Format a number with leading ones

    How do I format a number with leading ones or twos?
    This is what I'd do to format a number with 8 leading zeroes:
    String.format("%08d", 160)But, if I do the same with 8 leading ones, it does not work the way that I expect:
    String.format("%18d", 160)I'd appreciate your help.
    Thanks.

    933581 wrote:
    >
    What are you expecting?
    >
    I expected that "%18d" would pad with 1s.You assumed
    mmm I just thought that while "%08d" pads with 0s, the same would happen if I used "%18d" to pad with 1s.But if you would have looked at the javadoc of that method you would have very quickly known this was not the case and you wouldn't even had to create this thread. Why operate on guesswork when it is so easy to know reality? :(

  • Column format with percent ( % ) sign

    Is there column formatting for percent ( % ) signs?
    One of the fields in the report currently displays a number, e.g. "3.75", but need to add the percent ( % ) sign, e.g. "3.75%".
    I found the following:
    * To display "$5,234.10", I can use "FML999G999G999G999G990D00", this formats with a dollar ( $ ) sign and two decimal places.
    * To display "-5,234.10", I can use "S999G999G999G999G990D00", this formats with the sign ( + ) or ( - ) and two decimal places.
    However, I fail to find how to add the percent ( % ) sign...
    -Frank

    Thx for this hint. The only Problem with this solution is that the ‘%’ is also shown when the value is NULL.
    Has someone solved this also for NULL values where there should be nothing in the cell.
    Some solution but not very nice is to do this in the query itself.
    select ltrim(to_char(value, '999G999')||'%','%') from dual
    another one may by
    select to_char(b.COST_MATERIAL,'999G999L', 'NLS_CURRENCY = ''%''')
    from budget b

  • IR - Column with leading Zeros issue

    Hello,
    I've got an IR report which includes as "default report settings" 1 column with leading 0s. In order to export to Excel that column as text rather than as a numeric I followed a workaround proposed before in this forum (excel copy drops leading zeros
    In essence this workaround is to create an identifical column but in "excel text format" and display the columns depending on the request value: INSTR(NVL(:REQUEST,'YABBADABBADO'),'CSV') <> 0 for example.
    This works just fine for the default report.
    The problem arise when a user creates his own customise report that includes the mentioned column and saves it as a named report. Here, when the results are exported to excel the "excel" column does not appear.
    In fact, just hiding one of the displayed columns produces the same undesired result.
    I would appreciate any comments or suggestions.
    Many thanks
    Edited by: Javier Gil on Jul 20, 2010 7:52 AM

    I have found a better method. In your IR query:
    SELECT LPAD(v.vendor, 7, ' ') vendor,
    /*Just LPAD to a length of the column defined in the database table or to 7, whichever is greater. */
    FROM v, r
    WHERE v.VENDOR = r.VENDOR
    AND date_rcv <= to_date(:P150_CUTOFF,'yyyy/mm/dd')
    AND inv_nbr = ' '
    AND to_stores <> 'T'
    AND (V.VENDOR = RPAD(:P150_VENDOR,10,' ') OR :P150_VENDOR = 'ALL')
    When you download to Excel by Download/XLS (Request=XLS), it preserves the leading zeros.
    In the case of dates, you should LPAD 10 minimum in this format.
    LPAD(to_char(date_rcv,'MM/DD/YY'), 10, ' ') date_rcv,
    I haven’t tried it yet but I think in the case of ‘MM/DD/YYYY’, you should LPAD 12 minimum in this format.
    LPAD(to_char(date_rcv,'MM/DD/YYYY'), 12, ' ') date_rcv,
    Drawbacks of this method:
    Since the string has leading white spaces, you cannot use the filter for the ‘=’ comparison operator. Even filtering using leading white spaces will not return anything. You must use the LIKE and NOT LIKE operator instead.
    Advantages of this method over the original one I posted yesterday:
    1)     You do not have to create another column for download, just one column will suffice.
    2)     Even though the query has leading white spaces, they will not display in the IR region.
    Edited by: richardlee on Aug 5, 2010 11:10 AM
    Edited by: richardlee on Aug 5, 2010 11:16 AM

  • Printing value fields with negative sign??

    Hello Experts,
    I have developed a interface, which writes the invoice data to application server/unix, this is a notepad. My specifications are as below,
    MWSK1(2)   TaxCode                         65     2     KONV-MWSK1     
    KWERT(13)  Condition Value                  67     13   KONV-KWERT     
    KSTEU(1)  Condition Control                80     1     KONV-KSTE
    I have to print KWERT value from 67th position until 13 positions, meaning until 80 positions, fine. My code is as below,
      MOVE: wa_invoice_price-mwsk1  TO unix_file+64(2).
      WRITE: wa_invoice_price-kwert    TO unix_file+66(13) RIGHT-JUSTIFIED.
      MOVE:  wa_invoice_price-ksteu    TO unix_file+79(1),
    So, it printing like below (pls. note 0.04 minus value in right bottom corner)
    P26701ZCG620101006C          100.00         0.00USD  1    UGL            0.00A A 9
    P60001ZF3520101006C          100.00         0.00USD  1    UGLG          0.04-H B 9
    But, business want to have like below (pls. note the DIFFERENCE for 0.04 minus value in right bottom corner),
    P26701ZCG620101006C         100.00        0.00USD  1    UGL               0.00   A A 9
    P60001ZF3520101006C         100.00         0.00USD  1    UGLG             0.04 - H B 9
    meaning, the 13th position should be negative sign (if at all any value does have a negative sign, else its normal)....so, the negative sign should sit on 13th postion. As am using WRITE statement with RIGHT JUSTIFIED am facing thisissue!! as u know we can not send a 'P' type value to unix/apps server, pls. let me know how to get it done?
    Thank you

    why can't the user live with a leading sign, like '-   0.04'?  If possible, do
    shift <fieldname> circular up to '-'.
    Or, if value is less than zero, set another variable to '-', else set to space, and multiply value with '-1', like:
    if <field> < 0.
       lv_sign = '-'.                " neagtive value
      <field> = <field> * '-1'.  "reverse the sign
    else.
    lv_sign = space.          "positive value
    endif.
    then, adjust your field length and insert a sign column or simply add a column for the sign....

  • My computer keeps defaulting from a GB format to US format keyboard with a US flag in the top bar. How do I get it to go back to a GB flag and stay with a GB flag?

    My computer keeps defaulting from a GB format to US format keyboard with a US flag in the top bar. How do I get it to go back to a GB flag and stay with a GB flag?
    This only started 2 days ago.
    I have seen much on line as this seems to be a common problem, however none of the suggestions posted seem to work.

    Thanks Drew,
    On clicking the US flag I had previously then unchecked the US box. It has rechecked itself, and I have unchecked it again. The GB English remains checked.
    The flag icon has now gone completely from the top bar (just replaced with character and keyboard viewer) -but that's fine. That's different to previous attempts to fix the issue.
    Hopefully now I will remain able to type a £ sign on the keyboard rather than get the criss-cross symbol. It may well default back in about an hour (which is what has been happening since this started 2 days ago). If it does I'll come back on here. Many thanks in the mean time for your help.

  • Need formula to take text from one cell, add that to a serial number with leading zeros

    I'm trying to create a spreasdheet cell that simplifies creating videotape Numbers from a job name in cell and appends a serial number with leading zeros, and that would survive an export to EXCEL.
    The result would look like
     A Column
    Job Name
    B ColumnTape #
    Formula needed for B
    ClientName-TapeType-
    ClientName-TapeType-001
    =
    ClientName-TapeType-
    ClientName-TapeType-002
    =
    I've tried using a custom cell format that had the text in front of the (Integer) drag and drop, with three integers and leading zeros.
    That worked, but requires recreating the custom cell format for each client and tape type.
    So, I've used the formula =A2& in order to play around with different things, but haven't hit on something that adjusts for increased numbers and retains the leading zeros.
    I don't mind doing a starter for the first row and then adding +1 in the formulas for the rows below.
    I've done that using the custom cell formats for the first B cell and then using =Bx+1 in the following cells.  It works, but I'm hoping to find something simpler or that can be copied and pasted in multiple rows on one paste.
    Thanks in advance.
    Suggestions much appreciated!
    Ted

    Ted,
    This expression in B will give you the pattern I believe you are looking for:
    =A&RIGHT("00"&ROW()-1, 3)
    Here's a screen shot...
    Jerry

Maybe you are looking for