Cognos Analytics

Cognos Analytics

Connect, learn, and share with thousands of IBM Cognos Analytics users! 

 View Only
  • 1.  Removing Characters

    Posted Fri September 13, 2019 03:07 PM
    Edited by System Admin Fri January 20, 2023 04:16 PM



    ------------------------------
    Lisa
    ------------------------------

    #CognosAnalyticswithWatson


  • 2.  RE: Removing Characters

    Posted Fri September 13, 2019 04:05 PM
      |   view attached

    Hi Lisa,

    The attached picture has a field [code] that has some dashes in it.
    The field [code_1] removes the first dash from [code]
    The field [code_2] removes the first dash from [code_1]
    Sticking to standard functions only, so that it can be used for any SQL compliant database.

    The expression for code_1 is:
    IF ( POSITION ( '-' ; code ) > 0 )
    THEN ( SUBSTRING ( code ; 1 ; POSITION ( '-' ; code ) - 1 ) + SUBSTRING ( code ; POSITION ( '-' ; code ) + 1 ))
    ELSE ( code )

    and the one for code_2 is:
    IF ( POSITION ( '-' ; code_1 ) > 0 )
    THEN ( SUBSTRING ( code_1 ; 1 ; POSITION ( '-' ; code_1 ) - 1 ) + SUBSTRING ( code_1 ; POSITION ( '-' ; code_1 ) + 1 ))
    ELSE ( code_1 )

    Hope this helps.

    //Henk



    ------------------------------
    HENK CAZEMIER
    ------------------------------