COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: DiGzâ„¢747 on 19 Dec 2008 10:56:34 PM

Title: Using dash(-) in an IF-Statement
Post by: DiGzâ„¢747 on 19 Dec 2008 10:56:34 PM
Hi Guys,

I'm working in an enhancement right now and a particular data item on the report is required to convert zero values into a dash ('-').  I tried using the following statements below but I'm getting parsing error in each statement.

if([MI_PTD].[Budgt Hrs] =0) then('-') else ([MI_PTD].[Budgt Hrs])
if([MI_PTD].[Budgt Hrs] =0) then("-") else ([MI_PTD].[Budgt Hrs])
if([MI_PTD].[Budgt Hrs] =0) then '-' else ([MI_PTD].[Budgt Hrs])
if([MI_PTD].[Budgt Hrs] =0) then "-" else ([MI_PTD].[Budgt Hrs])

What character should I enclosed the dash character with? 

Hope you guys could help me out on this.

Regards,
Digz


Title: Re: Using dash(-) in an IF-Statement
Post by: Sunchaser on 20 Dec 2008 08:11:07 AM
Hi,

My opinion is that you shouldn't try to change the type of data return by your field "[MI_PTD].[Budgt Hrs]", by converting 0 to "-"; you'll have then mixed contents of number & char, I'm not sure it's good (if you have calculation somewhere).

Isn't it possible simply to use a conditionnal formatting based on "[MI_PTD].[Budgt Hrs]", the type will be boolean, the expression something like [MI_PTD].[Budgt Hrs]=0, and you'll change the text displayed in the report ("-" instead of 0) when the variable returns "true".

It's just an idea, It could be wrong depending on your case...

Hope it helps.
vinc.
Title: Re: Using dash(-) in an IF-Statement
Post by: VisioX on 23 Dec 2008 01:42:14 PM
Did you tried to set the "Zero Value Character" to "-" in the Data-Format?