If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Applying Style Variables to a regular table cell containing a singleton?

Started by holografix, 13 Mar 2011 07:26:56 PM

Previous topic - Next topic

holografix

Hi all,

This is a great forum! First of all just letting you guys know that I have spent 20 minutes searching for an answer to my question before I actually posted here.

This is probably a very simple question with a simple yes or no answer...

I defined 2 queries in Query Explorer (they are exactly the same with the exception that one filters for regular employees while the other for contractors etc).

I then went back into Page Explorer, and dragged-dropped a table object, into one of the cells I dragged-dropped a data item from the 1st query and into another cell I did the same with the 2nd query. I was prompted by a message box saying that a singleton had been added for each of of the data items.

I then added 2 style variables in Condition Explorer and proceeded to add those variables to the cells where the singletons resided.

BOOM. Cognos throws me an error and won't let me do it...  :(

If I however add the style variable to the singleton itself, it works fine.

Any ways to add a style variable to a table cell??! I'd like the background of that table cell to turn red in case X < 1

CognosPaul

I'm tempted to just write 'Yes', but I have a feeling you want the solution too.  ;D

The reason the variable doesn't work on the table cell is because the variable is attempting to reference a query item outside of the data container. You'll need to nest the singletons and the table. Take the following psuedocode example:
<Employee singleton>
   <Contractor Singleton>
      <table>
         <cell>
         <cell>
      </table>
   </singleton>
</singleton>


If you attempt to place the data item directly from the Employee query into the cell then it will throw an error, since the cell is in the context of the Contractor singleton. Go to the Employee singleton, click on properties and check the data item. Now drag in a layout calculation into the cell and pull in Employee.Value. Drag on the Contractor value. Now set the style variables and run it.

Below is an example on Cognos 10:
<report xmlns="http://developer.cognos.com/schemas/report/7.0/" useStyleVersion="10" expressionLocale="en-us">
<modelPath>/content/folder[@name=&apos;Samples&apos;]/folder[@name=&apos;Cubes&apos;]/package[@name=&apos;Sales and Marketing (cube)&apos;]/model[@name=&apos;2010-06-24T18:14:00.360Z&apos;]</modelPath>
<drillBehavior/>
<layouts>
<layout>
<reportPages>
<page name="Page1">
<style>
<defaultStyles>
<defaultStyle refStyle="pg"/>
</defaultStyles>
</style>
<pageBody>
<style>
<defaultStyles>
<defaultStyle refStyle="pb"/>
</defaultStyles>
</style>
<contents><singleton refQuery="Query2" name="Singleton2">
<contents><singleton refQuery="Query1" name="Singleton1">
<contents><table><style><defaultStyles><defaultStyle refStyle="tb"/></defaultStyles><CSS value="border-collapse:collapse"/></style><tableRows><tableRow><tableCells><tableCell>
<contents><textItem><dataSource><dataItemValue refDataItem="Revenue"/></dataSource></textItem></contents><style><CSS value="padding-right:5px;padding-left:5px"/></style>
<conditionalStyles><conditionalStyleCases refVariable="Revenue"><conditionalStyle refVariableValue="1"><CSS value="background-color:lime"/></conditionalStyle></conditionalStyleCases><conditionalStyleDefault>
<CSS value="background-color:red"/></conditionalStyleDefault></conditionalStyles></tableCell><tableCell><contents><textItem><dataSource><reportExpression>[Query2].[Planned revenue]
</reportExpression></dataSource></textItem></contents><style><CSS value="padding-right:5px;padding-left:5px"/></style><conditionalStyles><conditionalStyleCases refVariable="Planned revenue">
<conditionalStyle refVariableValue="1"><CSS value="background-color:lime"/></conditionalStyle></conditionalStyleCases><conditionalStyleDefault><CSS value="background-color:red"/>
</conditionalStyleDefault></conditionalStyles></tableCell></tableCells></tableRow></tableRows></table></contents>
</singleton></contents>
<propertyList><propertyItem refDataItem="Planned revenue"/></propertyList></singleton></contents>
</pageBody>
</page>
</reportPages>
</layout>
</layouts>
<XMLAttributes><XMLAttribute output="no" name="RS_CreateExtendedDataItems" value="false"/><XMLAttribute output="no" name="listSeparator" value=","/></XMLAttributes><classStyles>
<classStyle name="cls1" label="ParentRed"/><classStyle name="cls2" label="ParentGreen"/></classStyles><queries><query name="Query1"><source><model/></source><selection>
<dataItem name="Revenue"><expression>[sales_and_marketing].[Measures].[Revenue]</expression><XMLAttributes><XMLAttribute output="no" name="RS_dataType" value="9"/></XMLAttributes></dataItem></selection>
<slicer><slicerMemberSet>[sales_and_marketing].[Order method].[Order method].[Order method type]-&gt;:[PC].[@MEMBER].[601]</slicerMemberSet>
<slicerMemberSet>[sales_and_marketing].[Time].[Current Month].[Current Month]-&gt;:[PC].[@MEMBER].[Current Month]</slicerMemberSet></slicer></query><query name="Query2"><source><model/>
</source><selection><dataItem name="Planned revenue"><expression>[sales_and_marketing].[Measures].[Planned revenue]</expression><XMLAttributes><XMLAttribute output="no" name="RS_dataType" value="9"/>
</XMLAttributes></dataItem></selection><slicer><slicerMemberSet>[sales_and_marketing].[Order method].[Order method].[Order method type]-&gt;:[PC].[@MEMBER].[601]</slicerMemberSet>
<slicerMemberSet>[sales_and_marketing].[Time].[Current Month].[Current Month]-&gt;:[PC].[@MEMBER].[Current Month]</slicerMemberSet></slicer></query></queries><reportVariables><reportVariable type="boolean" name="Revenue">
<reportExpression>[Query1].[Revenue]&gt;=500000</reportExpression>
<variableValues>
<variableValue value="1"/>
</variableValues>
</reportVariable><reportVariable type="boolean" name="Planned revenue">
<reportExpression>[Query2].[Planned revenue] &gt;= 50000</reportExpression>
<variableValues>
<variableValue value="1"/>
</variableValues>
</reportVariable></reportVariables></report>