Search code examples
analyticscrosstabcognosmeasure

Cognos analytics multiple measures in a single cell


Is it possible to put multiple measures in a single crosstab cell? For example, put a 2x2 table in a cell and drop a measure in each cell of the table? I've tried doing that and the values just repeat across rows.


Solution

  • If you have a crosstab with time on the column edge and product line on the row edge, you can nest the Quantity and Revenue measure under the time, then set the box type to none on the labels so it looks like two values in a single cell. You may need to play around with the borders a bit too.

    Here is a sample spec:

    <report xmlns="http://developer.cognos.com/schemas/report/15.4/"           expressionLocale="en-us" useStyleVersion="11.5">
    
                    <drillBehavior/>
                    <layouts>
                        <layout>
                            <reportPages>
                                <page name="Page1">
                                    <style>
                                        <defaultStyles>
                                            <defaultStyle refStyle="pg"/>
                                        </defaultStyles>
                                    </style>
                                    <pageBody>
                                        <style>
                                            <defaultStyles>
                                                <defaultStyle refStyle="pb"/>
                                            </defaultStyles>
                                        </style>
                                        <contents><crosstab horizontalPagination="true" name="Crosstab1" refQuery="Query1">
                <crosstabCorner>
                    <contents/>
                    <style>
                        <defaultStyles>
                            <defaultStyle refStyle="xm"/>
                        </defaultStyles>
                    </style>
                </crosstabCorner>
    
    
                <noDataHandler>
                    <contents>
                        <block>
                            <contents>
                                <textItem>
                                    <dataSource>
                                        <staticValue>No Data Available</staticValue>
                                    </dataSource>
                                </textItem>
                            </contents>
                            <style>
                                <CSS value="padding:16px;"/>
                            </style>
                        </block>
                    </contents>
                </noDataHandler>
                <style>
                    <CSS value="border-collapse:collapse"/>
                    <defaultStyles>
                        <defaultStyle refStyle="xt"/>
                    </defaultStyles>
                </style>
            <crosstabColumns><crosstabNode><crosstabNestedNodes><crosstabNode><crosstabNodeMembers><crosstabNodeMember refDataItem="Revenue" edgeLocation="e3"><style><defaultStyles><defaultStyle refStyle="ml"/></defaultStyles><CSS value="display:none"/></style><contents><textItem><dataSource><memberCaption/></dataSource></textItem></contents></crosstabNodeMember></crosstabNodeMembers></crosstabNode><crosstabNode><crosstabNodeMembers><crosstabNodeMember refDataItem="Quantity" edgeLocation="e4"><style><defaultStyles><defaultStyle refStyle="ml"/></defaultStyles><CSS value="display:none"/></style><contents><textItem><dataSource><memberCaption/></dataSource></textItem></contents></crosstabNodeMember></crosstabNodeMembers></crosstabNode></crosstabNestedNodes><crosstabNodeMembers><crosstabNodeMember refDataItem="Year" edgeLocation="e1"><style><defaultStyles><defaultStyle refStyle="ml"/></defaultStyles></style><contents><textItem><dataSource><memberCaption/></dataSource></textItem></contents><propertyList><propertyItem refDataItem="Revenue"/><propertyItem refDataItem="Quantity"/></propertyList></crosstabNodeMember></crosstabNodeMembers></crosstabNode></crosstabColumns><crosstabRows><crosstabNode><crosstabNodeMembers><crosstabNodeMember refDataItem="Product line" edgeLocation="e2"><style><defaultStyles><defaultStyle refStyle="ml"/></defaultStyles></style><contents><textItem><dataSource><memberCaption/></dataSource></textItem></contents></crosstabNodeMember></crosstabNodeMembers></crosstabNode></crosstabRows><crosstabIntersections><crosstabIntersection row="e2" column="e3"><style><CSS value="border-right-style:none"/></style></crosstabIntersection><crosstabIntersection row="e2" column="e4"><style><CSS value="border-left-style:none"/></style></crosstabIntersection></crosstabIntersections><crosstabFactCell><contents><textItem><dataSource><cellValue/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="mv"/></defaultStyles></style></crosstabFactCell></crosstab></contents>
                                    </pageBody>
                                </page>
                            </reportPages>
                        </layout>
                    </layouts>
                <queries><query name="Query1"><source><model/></source><selection><dataItem aggregate="none" rollupAggregate="none" name="Year"><expression>[Sales (query)].[Time].[Year]</expression><XMLAttributes><XMLAttribute output="no" name="RS_dataType" value="1"/><XMLAttribute output="no" name="RS_dataUsage" value="0"/></XMLAttributes></dataItem><dataItem aggregate="none" rollupAggregate="none" name="Product line"><expression>[Sales (query)].[Products].[Product line]</expression><XMLAttributes><XMLAttribute output="no" name="RS_dataType" value="3"/><XMLAttribute output="no" name="RS_dataUsage" value="0"/></XMLAttributes></dataItem><dataItem aggregate="total" name="Revenue"><expression>[Sales (query)].[Sales].[Revenue]</expression><XMLAttributes><XMLAttribute output="no" name="RS_dataType" value="2"/><XMLAttribute output="no" name="RS_dataUsage" value="2"/></XMLAttributes></dataItem><dataItem aggregate="total" name="Quantity"><expression>[Sales (query)].[Sales].[Quantity]</expression><XMLAttributes><XMLAttribute output="no" name="RS_dataType" value="1"/><XMLAttribute output="no" name="RS_dataUsage" value="2"/></XMLAttributes></dataItem></selection></query></queries><XMLAttributes><XMLAttribute output="no" name="RS_CreateExtendedDataItems" value="true"/><XMLAttribute output="no" name="listSeparator" value=","/><XMLAttribute output="no" name="decimalSeparator" value="."/></XMLAttributes><modelPath>/content/folder[@name=&apos;Samples_LG_DQ&apos;]/folder[@name=&apos;Models&apos;]/package[@name=&apos;GO Sales (query)&apos;]/model[@name=&apos;model&apos;]</modelPath></report>