COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: Esosa on 19 Nov 2019 08:31:37 AM

Title: If A="EL" then A="Electrical"
Post by: Esosa on 19 Nov 2019 08:31:37 AM
Are if statements possible to switch the content of a string?

Lets say ServiceType = "EL" meaning that it is an Electrical Service Type. Is it possible to tell cognos to display in the report "Electrical" if ServiceType is equal to "EL" and "Water" if ServiceType is equal to "WTR"?




Thank you in advance
Title: Re: If A="EL" then A="Electrical"
Post by: BigChris on 19 Nov 2019 08:54:53 AM
IF and CASE statements both work fine in Cognos

if([ServiceType] = 'EL') then ('Electrical') else (if([ServiceType] = 'WTR') then ('Water') else ('Undefined'))

case ServiceType
  when 'EL' then 'Electrical'
  when 'WTR' then 'Water'
  else 'Undefined'
End