COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: inu on 12 Aug 2016 12:40:18 AM

Title: How Substitute macro function works in report studio
Post by: inu on 12 Aug 2016 12:40:18 AM
Hi Guys,

I went through google , but could get the clearance  from below macro expression is being used in template in my project.

#substitute('XYZ','Agreement Fact - Monthly',prompt('Par_Represent','token','[XYZ].[Time Dimension(Fiscal Calendar)].[Month Name]'))#

Can any one explain the use of the same with example..


Thanks
Inam
Title: Re: How Substitute macro function works in report studio
Post by: MFGF on 12 Aug 2016 03:48:55 AM
Quote from: inu on 12 Aug 2016 12:40:18 AM
Hi Guys,

I went through google , but could get the clearance  from below macro expression is being used in template in my project.

#substitute('XYZ','Agreement Fact - Monthly',prompt('Par_Represent','token','[XYZ].[Time Dimension(Fiscal Calendar)].[Month Name]'))#

Can any one explain the use of the same with example..


Thanks
Inam

Why did you go through google rather than just looking at the Information pane in the expression editor? Here's what it says:

substitute ( pattern_string, replacement_string, string_expression|array_expression )
Searches for a pattern in a string or in the string elements of an array and substitutes the first occurrence of "pattern_string" with "replacement_string".

Example: #sq ( substitute ( '^cn=', '***', 'cn=help' ) )#
Result: '***help'

Example: # csv ( substitute ( '^cn=', '***', array ( 'cn=help' , 'acn=5' ) ) ) #
Result: '***help', 'acn=5'

Example: # csv ( substitute ( 'cn=', '', array ( 'cn=help' , 'acn=5' ) ) ) #
Result: 'help', 'a5'

MF.