Cognos Analytics

 View Only
  • 1.  Period/Full stop in substitute macro causes query error

    IBM Champion
    Posted Wed February 28, 2024 11:24 AM
    Edited by Marc Reed Wed February 28, 2024 11:29 AM

    Hi all, in 11.2.3 this macro causes a query error:

    # sq( substitute( '$\.', 'ABC', '.') ) # 

    I have to escape the '.' character otherwise there is an error about a bad search pattern. I also want to use the special $ for the end of word. It seems the combination of $ prevents any substitution of a '.'.

    Anyone have any ideas on how to replace a '.; character? Thanks



    ------------------------------
    Marc Reed
    ------------------------------



  • 2.  RE: Period/Full stop in substitute macro causes query error
    Best Answer

    IBM Champion
    Posted Wed February 28, 2024 12:30 PM

    Try 

    # sq( substitute( '\.$', 'ABC', '.test.test2.test3.') ) # 
    If you want to replace every instance you could also do:
    # sq( join('ABC',split('.', 'test0.test1.test2.test3.')) ) # 


    ------------------------------
    Paul Mendelson
    ------------------------------



  • 3.  RE: Period/Full stop in substitute macro causes query error

    IBM Champion
    Posted Thu February 29, 2024 05:22 AM

    Thanks Paul. I hadn't spotted that the $ needs to be at the end of the string.



    ------------------------------
    Marc Reed
    ------------------------------