tags:

views:

1099

answers:

1

Hi all,

I've a list which has a column 'YEAR'. I want to make the recent year(2010) appear bold in that 'YEAR' column. I tried this expression

IF ( [myQuery].[YEAR] = [myQuery].[RECENT_YEAR]) THEN ( "RecentYearBold" )

where [RECENT_YEAR] is a DataItem with the expression maximum([YEAR])

This throws me an error and it doesn't allow me to use the DataItem in conditional variable expression. Can anybody help?

Error I get:

RSV-VAL-0002 Invalid expression IF ( [myQuery].[YEAR] = [myQuery].[RECENT_YEAR] ) THEN ( "RecentYearBold" ). CRX-API-0005 An error on or around the position '34'. The variable named '[myQuery].[RECENT_YEAR]' is invalid.

+1  A: 

I was able to accomplish what you are trying (after getting the same error you did) by taking the following approach:

  1. I created the [recent_year] column to be the following: maximum ([cognos_test].[year] for report). (You could use a different scope, if desired.)
  2. Created a boolean variable in Conditon Explorer called recent year with the following expression: [Query1].[year] = [Query1].[recent_year]
  3. I added the year column to the list, set the style variable = recent year and applied the conditional bold formatting to the year column when recent year = true
  4. At this point, when I executed the report, I received the same error you did. Validating the report gave a little more information, which indicated that the [Query1].[recent_year] field needed to be in the list as well. When I added it to the list, the conditional formatting worked. (Really not sure why this was the case, but I went with it.)
  5. To hide the [recent_year] column (while still leaving it in the list) you can set the "Box Type" property for the "List Column Body" and "List Column Title" objects for the recent_year column to "None".
Jamey
first of all thanks for your reply... coz i was waiting for a week to get this mystery solved. Yes as you said, i should not 've underestimated the 'validate' option... Thanks yaar. thanks a lot...
Veer
does that maximum keyword work for you? I want the entire recent_year column to contain '2010' only. Any help?
Veer
Your post indicates you want to highlight rows containing 'recent year', not filter the results. If you just want to see records containing recent year, use the expression in #2 above in a report filter.
Jamey
Actually i want to highlight rows containing the recent year 2010. That's correct.But the issue is that i'm not able to get the recent_year using any expression because my [year] column has many duplicates. so when maximum([year]) is used it just groups up the year I think you can understand my table data by this query... select year,count(year) from tbl_Time group by year order by year returns -> YEAR COUNT(YEAR) 2004 53 2005 52 2006 52 2007 63 2008 62 2009 63 2010 9... Any ideas how to retrieve the recent_year from this? I think instead of depending on model i've to go for native sql
Veer
When you create your conditional expression, do specify the scope with "for report"? Using the "for" scope operator will instruct Cognos to ignore the groupings in your query when determining which row(s) to highlight.
Jamey
Can you elaborate it?
Veer