Truncate numbers from string field

Afternoon all,
This time I'd like to extract only 2 strings out of a string field. The field is of sales area which contains numbers and letters. For example, Scotland is given a number 01, West midlands is 02, Ireland however is given IR.
however, the field which holds the information is like, 012, where 01 is the area number and 2 is type of area number.
The information which we are interested in is first two strings.
I have tried this in the formula given below but it doesn't work, it states a field is required
If hasvalue({?Sales Area}) then
totext(Minimum({slslsp.slr_slsperson}[1 to 2])) + " - " +
totext(Maximum({slslsp.slr_slsperson}[1 to 2]))
else
"n/a"
Should I be using a truncate and if yes then how?
P.S. This is to show only the sales area number or text if selected under a parameter. The values of the parameter will stay the same. In other words it is just to show in the report.
Many thanks once again
Regards
Jehanzeb

Is it a range parameter? If so try this
If hasvalue({?Sales Area}) then
totext(Minimum({slslsp.slr_slsperson})[1 to 2]) + " - " +
totext(Maximum({slslsp.slr_slsperson})[1 to 2])
else
"n/a"
regards,
Raghavendra.G
Edited by: Raghavendra Gadhamsetty on Jan 16, 2009 4:16 PM

Similar Messages

  • Extraction of Numbers from string in oracle

    Dear All,
    I have a AplhaNumeric field in my source table which holds the string with numbers and caharcters .i need to extract only numbers and to load into the target table which of number type.
    can any one suggest me about how to do this?
    regards
    kumar

    Hi ,
    I have a table called smitems with column smitmqtyremarks which holds alpha numeric characters .nearly 180 records exists in this table.
    i need extract numbers for this field and load into my target tables.
    here i am giving sample rows for this field :
    smitmqtyremarks
    13 قطعة
    4 لحاف
    31 قطعة
    120 قطعة
    57 قطعة
    110 قطعة
    127قطعة
    169 قطعة
    12 مفرش
    10 مفارش
    110 قطعة
    170 قطعة
    20 خرطوشة
    28 قطعة
    60قطعة
    70 قطعة
    80 لعبة
    70 قطعة
    20 قطعة
    60 قطعة
    50 قطعة
    10 رولات
    4 رولات
    35 دسته
    50دستة
    7 رول
    3 اثواب قماش
    خمسة خرطوشة سجائر
    50 جاكت حريمى ورجالى
    10 رول اقمشة 4 دسته
    420 جوارب اطفال
    60 خرطوشة سجائر
    12 رول
    15 خرطوشة
    110 علبة
    45 قطعة
    40 قطعة
    44 قطعة
    22 قطعة
    3 خرطوشة
    468 قطعة
    38 قطعة
    80 رول قماش
    2 رول
    6 رول اقمشة
    13 رول اجنبى الصنع
    100 دسته صينى الصنع
    18 رولات ملابس
    10دسته
    90قطعة
    33 قطعة
    39 قطعة
    42 قطعة
    300 ايشارب
    500 قطعة
    19000 ك 0ج
    607 قطعة
    24 قطعة
    45 قطعة
    40 اروسه
    5 رول اقمشة اجنبية الصنع
    75 قطعة
    5 قطعة
    4 رول
    26 قطعة
    50قطعة
    105 قطعة
    650 جرام
    65 قطعة
    50 خرطوشة
    4 خرطوشة
    80 قطعة
    100 بنطلون
    500 قطعة
    40 قطعة
    42قطعة
    1 خرطوشة
    14 قطعة
    80 قطعة
    7 خرطوشة سجائر
    230 لمبة
    50 قطعة
    50قطعة تليفون
    14 كرتونة
    4 كرتونة احذية
    17 كرتونة خزف
    22 لحاف
    16كرتونة ادوات صحية
    8كرتونة
    28 كرتونة
    2كرتونة
    15كرتونة
    115 قطعة
    6448
    1937قطعة
    1937 قطعة
    2628كجم
    6.980طن
    9 كرتونة
    18 شفاط
    صواميل حديد
    3كرتونة +20 قطعة
    39.480طن ق.غ سيارات
    25كرتونة مصنوعات خزفية
    50بنطلون
    8 كرتونة كلبسات
    20كرتونة اكسسوار حريمى
    279كرتونة لحوم
    38 اطار كاوتش
    10كرتونة
    4كرتونة
    10كيلو
    عدد5 ماكينات
    41سيارة
    سيارة
    90 قطعة ملابس
    22250كجم
    1793كجم
    1371كرتونة زجاج
    مستندى
    252شاشة
    5كرتونة
    320قطعة
    45خرطوشة
    98 قطعة
    10لفات
    25كجم
    320كجم
    5كراتين
    47طرد
    50قطعة
    117كجم
    1200 قطعة ملابس
    5كجم
    75جهاز
    40قطعة
    5كراتين
    10كجم
    250ق
    200ق
    200 توب
    20لفة
    30لفة
    2دستة
    95قطعة
    70قطعة
    57523طن طلمبات مياه
    43732كجم
    755كرتونة
    10.645طن
    1537طرد
    11751كجم
    مكبس
    77426.80متر
    2600قطعة
    339طن
    15120كجم
    مختلفة
    267طرد
    1200كجم
    189عبوة
    499كرتونة
    10000كجم
    960طرد
    15.770كجم
    111قطعة
    174طرد
    22000كجم
    473000علبة
    6720كجم
    145خرطوشة
    2500طن
    3660كجم
    27824كجم
    8682كجم
    14000كجم
    6400كجم
    133كرتونة
    2738كجم
    the characters are in arabic here.
    hope it clears my issue.
    please suggest me the right query for this to get only numbers
    thanks
    kumar

  • Removing last 2 characters from string field

    I am trying to remove the last 2 characters of a string field.
    there is no consistant length in the field
    316R1
    12364R1
    i want to remove everything after R
    i tried instrrev but i that didnt do it.
    is there a way to say
    start position1 and go the R
    thanks

    formula,
    left (field, length_formula) is the solution
    the length_formula is the number of chars form left
    f.i
    left(field, length (field)-2)
    left (field, InstrRev, field,"R")
    of course a combination with Right is also possible

  • Remove leading numbers in string field

    I have a string field "01-Submitted" and wold like to remove the "01-".  How can this be done?

    Hi Create a formula:
    split(field,"-")[2];
    place this in the detail and see if prints the values.
    Regards,
    Vinay

  • Separation of Numbers from string

    Hi All,
    In my project i have a requirement where i need to remove the numerical values from the given string ...
    For ex My input:CLWMEK0299
    Expected Output : CLWMEK
    Kindly please let me know ASAP... '
    Thanks and regards,
    Sudarshan
    Edited by: Sudarshan on Mar 28, 2012 9:51 PM

    Look at this SQLPLUS:
    SQL> select regexp_replace('123abc', '[0-9]','') from dual;
    REG
    abc
    SQL> select regexp_replace('1a7bc', '[0-9]','') from dual;
    REG
    abc
    SQL> create table T ( Text varchar2(20));
    Table created.
    SQL> insert into T values ('12abc345');
    1 row created.
    SQL> insert into T values ('abc12345');
    1 row created.
    SQL> insert into T values ('123abc');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select regexp_replace(Text, '[0-9]','') from T;
    REGEXP_REPLACE(TEXT,'[0-9]','')
    abc
    abc
    abc
    IN OBIEE front end - Suppose in the column formual of column - Prod_desc - You have to use evaluate function - like this -
    EVALUATE ('REGEXP_REPLACE(%1,%2,%3)',"PRODUCTS"."PROD_DESC",'[0-9]','')

  • Parsing multiple digit numbers from string

    I have a string, specifically "Cups = 30" that I need to parse out "30" from. How can I do this? I've gone through tokenizing, it's dirivng me crazy!!

    This program will help you
    import java.util.*;
    class s21
    public static void main(String args[])
    try
    String s1="Cups=30";
    StringTokenizer st=new StringTokenizer(s1,"=");
    while(st.hasMoreTokens())
    st.nextToken();
    System.out.println(st.nextToken());//This statement will
    give 30 as output
    catch(Exception e)
    System.out.println(e);

  • JCo getting truncated value from SAP when field data type is RAW

    We are trying to fetch data from a SAP-AII table by using JCo using the RFC RFC_READ_TABLE.
    We are getting incomplete data when the data type of the column is RAW in a particular table.A typical case is:
    Table Name: /AIN/DM_DEVCTR
    Field : CLIENT                Type: CLNT    Length:3      Value: 100                                                            (SAP Generated)
    Field:  DEVCTR_GUID    Type:RAW      Length:16    Value: 306F50F53805ED488DE9797AC86B5728     (SAP Generated)
    Filed:  DEVCTR_ID         Type:CHAR    Length:128   Value: KDEVICECONTROLLER                             (User input)
    For the fields CLIENT and DEVCTR_ID we get the entire value (including blank spaces) but for DEVCTR_GUID we get only 16 characters whereas SAP-AII stores a value that is 32 characters in length. How do we fetch the actual value instead of the truncated value?
    Sample code is attached.
              try {
                   mConnection = JCO.createClient("100", // SAP client
                             "User", // userid
                             "Password", // password
                             "EN", // language
                             "SAP", // host name
                             "00"); // system number
                   mConnection.connect();
                   if (mConnection == null) {
                        System.out.println("Connection to SAP Server failed.");
                   mRepository = new JCO.Repository("User", mConnection);
                   ftemplate = mRepository.getFunctionTemplate("RFC_READ_TABLE");
              } catch (Exception ex) {
                   ex.printStackTrace();
                   System.exit(1);
              JCO.Function function = ftemplate.getFunction();
              JCO.ParameterList importParamList = function.getImportParameterList();
              importParamList.setValue("/AIN/DM_DEVCTR", "QUERY_TABLE");
              importParamList.setValue(";", "DELIMITER");
              JCO.Table tableData = function.getTableParameterList().getTable("DATA");
              JCO.Table fields = function.getTableParameterList().getTable("FIELDS");
              mConnection.execute(function);
              if (tableData.getNumRows() > 0) {
                   do {
                        for (JCO.FieldIterator e = tableData.fields(); e
                                  .hasMoreElements();) {
                             JCO.Field field = e.nextField();
                             String str = field.getString();
                             String[] values = str.split(";");
                             for(int i = 0; i < values.length; i++){
                                  System.out.println(values<i>);
                   } while (tableData.nextRow());
              } else {
                   System.out.println("No results found");
              mConnection.disconnect();

    Hi Kaanu,
       You have to modify your java code.
    String val = new String( field.getByteArray());
    PS: Please reward points for helpful answer or problem resolved.

  • Updated to CR 2008 - now have new problem with truncated String fields.

    Hi there
    I'm hoping someone has a simple answer for this one...  notice there's a lot of it on forums but I haven't found an answer.
    Since updating to Crystal 2008 (Crystal 12), we have found that some reports are suddenly truncating string fields at 255 characters, despite the field value being much longer in the database.
    Does anyone know what to do to allow these fields to print in completion?
    Database connection is ODBC RDO.
    regards
    -Karen

    What is the database Oracle, SQL server etc.
    Can you query the database directly with another query tool, eg SQL Server Management Studion or SQL developer/Toad for Oracle.
    You can then run the Crystal query directly and see if its your ODBC connection that is truncating the datafield or Crystal.
    I have memo fields on SQL server with up to 2000 characters and these display in Crystal 2008 without any problem. We use ODBC (RDO) too.
    Ian

  • Extract numbers from mixed string.

    How do I extract numbers from a mixed-character string?
    These are house numbers and I have some exceptions - examples below.
    How do I get rid of the letter/dash part, and keep the numeric part only?
    38A
    5600B
    23-A
    Thanks a lot.
    -John

    It does not work if you have a string like 3343S##@1~!234
    OP, you can try this:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> with t as(
      2      select '38A' c1 from dual union all
      3      select '5600B' from dual union all
      4      select '5Bas@#$%1SDf3ff`~7' from dual union all
      5      select '3343S##@1~!234' from dual union all
      6      select '23-A+9' from dual )
      7  --
      8  select c1,regexp_replace(c1,'[^[:digit:]]') only_num  from t;
    C1                 ONLY_NUM
    38A                38
    5600B              5600
    5Bas@#$%1SDf3ff`~7 5137
    3343S##@1~!234     33431234
    23-A+9             239
    SQL>

  • Removing number appended at the end from a string field

    Hi,
    I have a string field which has numbers appended to its end. I need to remove the numbers and display only the string values.
    The string is not of fixed length, and the numeric values can be single digit or 2 digits and might be separate by a space but not always.
    Here is some sample data:
    SHOWCASE NOTT12
    SHOWCASE PETE12
    SHOWCASE BRIST7
    SHOWCASE READI1
    CINEDROME PAD1
    RITZ BELPER   1
    STEPH.JOSEPH S1
    I need to display this as below (without any numbers appended at the end)
    SHOWCASE NOTT
    SHOWCASE PETE
    SHOWCASE BRIST
    SHOWCASE READI
    CINEDROME PAD
    RITZ BELPER  
    STEPH.JOSEPH S
    Please let me know how this can be achieved.
    Thanks!

    Hi there,
    Just a quick option is to use the REPLACE function, i.e.
    REPLACE(REPLACE(REPLACE({contr_actv.dept_id},'1' ,''),'2', ''), '3', '');
    You just have to build it up a little more so it caters for numbers 0 - 9.  At the moment it only works for numbers 1 - 3.  Another way you could do this is write some code to loop through the length of the string looking at each individual character to test for a number.
    I don't have time today to write something like that but the above should work as long as you don't have numbers in the middle of names etc.
    Cheers,
    Chris

  • String Field rendering as Number Field in CR Basic for VS2008

    I recently migrated from CR for VS2005 to CR Basic for VS2008 and am creating my first report using CR 2008. The SQL result set returns rows containing strings (nvarchar), integers and decimal (7,2) fields.
    The report is getting all rows in the result set, but the string fields as defined in the SQL are 1) rendering in the report as numbers, and 2) showing as empty. The non-string fields render fine. I tried reformatting the report field to string, but only the Number tab appears in the formatting dialog. I also tried converting the SQL field result into an unbound string field, as well as tried the ToText function, but the results were the same. I suspect the field appears empty because of the formatting issue.
    How can I get CR Basic for VS2008 to render a string (nvarchar) field as a string?

    Try placing the field inside a formula field or inside a text field.  That should cause the field to be shown no matter what type of data it is.  If the data is still not showing, then perhaps it is not being returned properly. 
    Things to check:
    -Are you connecting directly to the tables - or are you connecting to a stored procedure?  If you are connecting to a stored procedure and you are using Temp Tables, then make sure you add the line "SETNOCOUNT ON" to your stored proc.
    -Run SQL profiler - see what query is being made, then try running that exact same query through the SQL admin console (Or some other utility that lets you run SQL queries)
    Thanks
    Shawn

  • Conversion from string "20041023 " to type 'Date' is not valid.

    Hi ,
       I have a table with one of the column(EmpHiredate) datatype is char(10). It has value like "20141023". I need to display this value as date format(dd/mm/yyyy) in report. 
    Following methods i tried in textbox expression but no luck.
    =Format(Fields!EmpHireDate.Value,"dd/MM/yyyy")
    =Cdate(Fields!EmpHireDate.Value)
    Error:
    [rsRuntimeErrorInExpression] The Value expression for the textrun ‘EmpHireDate.Paragraphs[0].TextRuns[0]’ contains an error: Conversion from string "20041023  " to type 'Date' is not valid.
    Is it possible to convert string to date using SSRS textbox expression ? Can anyone help me with the solution.
    Thanks,
    Kittu

    Hi Jmcmullen,
         Found one more issue on the same. I have one value like "00000000" for the column(EmpHiredate)
    , when i use above expression values(ex:"20141023")
    are displaying in dd/MM/yyyy format in report except value like "00000000" and giving following error:
    [rsRuntimeErrorInExpression] The Value expression for the textrun ‘EmpHireDate.Paragraphs[0].TextRuns[0]’ contains an error: Conversion from string "0000/00/00" to type 'Date' is not valid.
    Even i tried to pass its original value("00000000") as below but no luck.
    =IIF(Fields!EmpHireDate.Value = "00000000","00000000",Format(CDATE(MID(Fields!EmpHireDate.Value,1,4) + "/" + MID(Fields!EmpHireDate.Value,5,2) + "/" + MID(Fields!EmpHireDate.Value,7,2)),"dd/MM/yyyy"))
    Also tried this:
    =IIF(Fields!EmpHireDate.Value = "00000000","2000/10/21",Format(CDATE(MID(Fields!EmpHireDate.Value,1,4) + "/" + MID(Fields!EmpHireDate.Value,5,2) + "/" + MID(Fields!EmpHireDate.Value,7,2)),"dd/MM/yyyy"))
    Please Suggest. 
    Thanks ,
    Kittu

  • A record selection problem with a string field when UNICODE database

    We used report files made by Crystal Reports 9 which access string fields
    (char / varchar2 type) of NON-UNICODE database tables.
    Now, our new product needs to deal with UNICODE database, therefore,
    we created another database schema changing table definition as below.
    (The table name and column name are not changed.)
        char type -> nchar type
        varchar2 type -> nvarchar2 type
    When we tried to access the above table, and output a report,
    the SQL statement created from the report seemed to be wrong.
    We confirmed the SQL statement using Oracle trace function.
        SELECT (abbr.) WHERE "XXXVIEW"."YYY"='123'.
    We think the above '123' should be N'123' because UNICODE string
    is stored in nchar / nvarchar2 type field.
    Question:
    How can we obtain the correct SQL statement in this case?
    Is there any option setting?
    FYI:
    The environment are as follows.
        Oracle version: 11.2.0
        ODBC version: 11.2.0.1
        National character set: AL16UTF16

    With further investigating, we found patterns that worked well.
    Worked well patters:
        Oracle version: 11.2.0
        ODBC version: 11.2.0.1
        National character set: AL16UTF16
        Report file made by Crystal Reports 2011
        Crystal Reports XI
    Not worked patters:
        Oracle version: 11.2.0 (same above)
        ODBC version: 11.2.0.1 (same above)
        National character set: AL16UTF16 (same above)
        Report file made by Crystal Reports 2011 (same above)
        Crystal Reports 2008 / 2011
    We think this phenomenon is degraded behavior of Crystal Reports 2008 / 2011.
    But we have to use the not worked patters.
    Anything wrong with us? Pls help.
    -Nobuhiko

  • Grabbing numbers from an array of type double and outputting them into a text file

    In a program im creating i need to save some coordinates of a micropositioner i have into a text file,
    I have the coordinates saved into an array that has 6 digits of precision (6 places after the decimal point).
    I use the number to string conversion and wire that into the write to text file function in labview.  When i open the file
    the numbers that are only displayed are the ones to the left of the decimal point.  I know the number to decimal string function
    rounds the values so if i were to input 3.111111 it would only output the string "3" instead of "3.111111" . 
    So to get all the digits onto the file without rounding i multiplied the number by 10^6 but the decimal point will be lost at that point.
    Is there anyway i can convert numbers into strings without labview rounding to the nearest whole number also without having to multiply by 10^6 and without having to expect the user to know that the coordinates saved in a file are multiplied by an order of magnitude of a million ? 

    ed oh i guess i just missed that function on the pallete after i saw that the function went from number to hex, octal, etc. i assumed that the rest on that row would be some sort of conversion to a different base number, haha thanks.

  • How to retrieve Numbers from xml data

    if I have this data..
    <bids>
    <bid_tuple>
    <userid>U01</userid>
    <itemno>1004</itemno>
    <bid>40</bid>
    <bid_date>1999-03-05</bid_date>
    </bid_tuple>
    <bid_tuple>
    <userid>U03</userid>
    <itemno>1007</itemno>
    <bid>175</bid>
    <bid_date>1999-01-25</bid_date>
    </bid_tuple>
    <bid_tuple>
    <userid>U05</userid>
    <itemno>1007</itemno>
    <bid>200</bid>
    <bid_date>1999-02-08</bid_date>
    </bid_tuple>
    <bid_tuple>
    <userid>U04</userid>
    <itemno>1007</itemno>
    <bid>225</bid>
    <bid_date>1999-02-12</bid_date>
    </bid_tuple>
    </bids>
    stored in xmltype table called bids
    I want to run this query...
    select extract(OBJECT_VALUE,'/bids/bid_tuple/itemno/text()').getnumberval() from bids;
    it give me .. 1.0011E+63
    Which I DO NOT NEED
    I need numbers not string since extract or extract vlaue will return string AND using getNumberVal() will give me this strange result
    I need it since I want to compare the result with data from relational table
    Thanks

    NinaOracle wrote:
    select extract(OBJECT_VALUE,'/bids/bid_tuple/itemno/text()').getnumberval() from bids;That extracts and concatenates all itemno text nodes from the document into a single (possibly long) string.
    With getNumberVal you then try to convert the string to a (possibly big) number, hence the display "issue".
    If you want to break the XML into relational rows and columns, XMLTable is your choice :
    SQL> SELECT x.itemno
      2  FROM bids b,
      3       XMLTable(
      4        '/bids/bid_tuple/itemno'
      5        passing b.object_value
      6        columns
      7         itemno number path '.'
      8       ) x
      9  ;
        ITEMNO
          1004
          1007
          1007
          1007

Maybe you are looking for

  • Trail balance

    Hi Sap Gururs Can Any Body Tell me how many trial balances we caqm create For A company Code, I mean to say We can create trial Balaces Like Business Area wise Cost Center Wise. Etc, Like tht Totally how many options available in reporting a trial ba

  • Msa 50sp6: outlook integration not possible

    Hello forum, while installing msa50sp6 with outlook integration, I do not get any buttons/tabs into my outlloók 2002. No errors while installing. (outlook is closed while installing). Is it possible to install the outlook sync. manual ? Or has anybod

  • TDS certificate:Quarter Acknowledgement no. is not appearing in certificate

    Hi gurus, It is apearing like Quarter Acknowledge no. 1.          N. A. 2.          N.A. 3.          N.A. 4.          N.A Pl advise how it can appear in certificate. Regards, Samar

  • Unable to drop publication database from publisher server in transactional replication

    Dear All, we are getting one issue when the time of dropping publication database on publisher server in transactional replication in sql server 2008 r2. TITLE: Microsoft SQL Server Management Studio Could not delete publication 'dbname_Pubs'. For he

  • Datatransferservice CDTS Job DTS Job Bits Errorcode 0x801901F4

    I have a new build of Server 2012 R2, SCCM 2012 R2 CU2, and SQL 2012 SP1 CU6. This same set of software works on another network. On the new network, I'm not been able to get any updates working that come through All Software Updates. 3rd Party Updat