COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: div_1234 on 22 Aug 2011 12:23:24 PM

Title: how to dislay conditionally item in cognos
Post by: div_1234 on 22 Aug 2011 12:23:24 PM
hi

i want to display 'P' OR 'F' in one of the field.ex, if *quantity = 1 then 'P' else'F'
how can i displayit  in measure .i created variable but its nt working .


any help?
Title: Re: how to dislay conditionally item in cognos
Post by: Lynn on 22 Aug 2011 01:32:05 PM
Did you create a data item with your expression? When you say "display it in measure" are you referring to a crosstab? I don't understand what you tried that isn't working.
Title: Re: how to dislay conditionally item in cognos
Post by: div_1234 on 24 Aug 2011 10:14:33 AM
i have one filed on sp whose value is 1/0 in sp,but i want to display if 1 then 'P' else 'F'in report studio.

and this all comes from 1 column

for ex. if val = 1 them min,
               val 2 then max,
              val 3 then 1/0 as column





now this column i just drag into crosstab report ,but  i am not able to chnage 'p/f'

thanks
Title: Re: how to dislay conditionally item in cognos
Post by: MFGF on 24 Aug 2011 10:58:29 AM
Are you trying to use this in the row/column headings of your crosstab or in the measure cells? If it's the former, just add a query calculation and code an expression similar to this:

if ([your quantity item] = 1) then ('P') else ('F')

This will not be valid for the cells though.  The cells of a crosstab can only display aggregated numeric items, not text.

Regards,

MF.
Title: Re: how to dislay conditionally item in cognos
Post by: div_1234 on 24 Aug 2011 01:03:51 PM
hi
its in measure,i dont know  how to do in that
Title: Re: how to dislay conditionally item in cognos
Post by: MFGF on 25 Aug 2011 06:56:47 AM
Quote from: div_1234 on 24 Aug 2011 01:03:51 PM
hi
its in measure,i dont know  how to do in that

You can't. The cells of a crosstab can only display aggregated numeric items, not text.

Regards,

MF.
Title: Re: how to dislay conditionally item in cognos
Post by: Lynn on 25 Aug 2011 07:18:30 AM
You can't use a non-numeric item as a measure in a crosstab, but you can use a layout calculation to do what you have described:




case [Query1].[YourQuantityItem]
when 1 then 'P' 
when 0 then 'F'
else ''
end


Title: Re: how to dislay conditionally item in cognos
Post by: div_1234 on 25 Aug 2011 10:02:11 AM
hey Lynn,

Thanks its working fine for simple data,but my data is coming from column which has case statement in SP,i dont know how to use it in a expression.Any Idea?
Title: Re: how to dislay conditionally item in cognos
Post by: Lynn on 25 Aug 2011 10:22:42 AM
I don't understand the problem. A query item sourced from a column in a table or a column in a view or a column in a SP is still just a query item that returns something of a particular data type.

The expression within the view or SP wouldn't prevent you from referring to it the same way you would refer to a column in a table.

Did you try it and get an error  or something?
Title: Re: how to dislay conditionally item in cognos
Post by: div_1234 on 25 Aug 2011 12:02:49 PM
the thing is i have 1 column, which comes frm sp as

if val = 1 then 1,
val=2 then 2 as quantity.

Now i am dragging quantity in my report, it display like this in column

1| 2
i m putting case like

if val = 2
then ......
i just  want to do for 2,but everything comes as p/f

Title: Re: how to dislay conditionally item in cognos
Post by: Lynn on 25 Aug 2011 03:15:51 PM
Sorry, I'm still not following you.

You put the quantity data item into the crosstab as a measure, correct?

Then you unlock the report and drag in a layout calculation, correct?

What is the expression syntax for that layout calculation?

Is the layout calculation expression where the problem is? What do you mean by "i just  want to do for 2,but everything comes as p/f"?
Title: Re: how to dislay conditionally item in cognos
Post by: div_1234 on 25 Aug 2011 07:45:02 PM
plz see the attachement