在 Cognos 中创建值数组

Create array of values in Cognos

有没有办法在 Cognos Report Studio 中为给定字段创建值数组?

假设一项费用有 5 名参加者。如果我引入字段费用和与会者,这将创建 5 行,因为粒度被强制降低到与会者级别而不是费用级别。

我可以将其强制返回一行,其中参与者列是逗号分隔值或某种数组吗?

摘录:

+---------+----------+-----------+------------+
| Expense | Employee | Entry Key | Attendee   |
+---------+----------+-----------+------------+
| Meal    | Iron Man | 1         | Thor       |
+---------+----------+-----------+------------+
| Meal    | Iron Man | 1         | Hulk       |
+---------+----------+-----------+------------+
| Meal    | Iron Man | 1         | Spider Man |
+---------+----------+-----------+------------+
| Meal    | Iron Man | 1         | Star Lord  |
+---------+----------+-----------+------------+
| Meal    | Iron Man | 1         | Thanos     |
+---------+----------+-----------+------------+

所需的提取物:

+---------+----------+-----------+-------------------------------------------+
| Expense | Employee | Entry Key | Attendee                                  |
+---------+----------+-----------+-------------------------------------------+
| Meal    | Iron Man | 1         | Thor, Hulk, Spider Man, Star Lord, Thanos |
+---------+----------+-----------+-------------------------------------------+

限于计算 fields/equations 假设这将采用子查询,然后使用输入键连接回完整查询。不确定这在计算字段中是否可行

使用具有复杂查询结构的转发器 table 以仅在值之间包含逗号(而不是在开头或结尾)。这是一个示例报告: 你没有说什么版本的 Cognos。这是针对 11.0.13 的。您可能需要更新第一行中的版本号和样式版本以匹配您的环境。

<report xmlns="http://developer.cognos.com/schemas/report/14.3/"           useStyleVersion="11.4" expressionLocale="en-us">
    <drillBehavior/>
    <layouts>
        <layout>
            <reportPages>
                <page name="Page1">
                    <style>
                        <defaultStyles>
                            <defaultStyle refStyle="pg"/>
                        </defaultStyles>
                    </style>
                    <pageBody>
                        <style>
                            <defaultStyles>
                                <defaultStyle refStyle="pb"/>
                            </defaultStyles>
                        </style>
                        <contents>
                            <list horizontalPagination="true" name="List1" refQuery="Query3">
                                <noDataHandler>
                                    <contents>
                                        <block>
                                            <contents>
                                                <textItem>
                                                    <dataSource>
                                                        <staticValue>No Data Available</staticValue>
                                                    </dataSource>
                                                    <style>
                                                        <CSS value="padding:10px 18px;"/>
                                                    </style>
                                                </textItem>
                                            </contents>
                                        </block>
                                    </contents>
                                </noDataHandler>
                                <style>
                                    <CSS value="border-collapse:collapse"/>
                                    <defaultStyles>
                                        <defaultStyle refStyle="ls"/>
                                    </defaultStyles>
                                </style>
                                <listColumns>
                                    <listColumn>
                                        <listColumnTitle>
                                            <style>
                                                <defaultStyles>
                                                    <defaultStyle refStyle="lt"/>
                                                </defaultStyles>
                                            </style>
                                            <contents>
                                                <textItem>
                                                    <dataSource>
                                                        <dataItemLabel refDataItem="Country"/>
                                                    </dataSource>
                                                </textItem>
                                            </contents>
                                        </listColumnTitle>
                                        <listColumnBody>
                                            <style>
                                                <defaultStyles>
                                                    <defaultStyle refStyle="lc"/>
                                                </defaultStyles>
                                            </style>
                                            <contents>
                                                <textItem>
                                                    <dataSource>
                                                        <dataItemValue refDataItem="Country"/>
                                                    </dataSource>
                                                </textItem>
                                            </contents>
                                        </listColumnBody>
                                    </listColumn>
                                    <listColumn>
                                        <listColumnTitle>
                                            <style>
                                                <defaultStyles>
                                                    <defaultStyle refStyle="lt"/>
                                                </defaultStyles>
                                            </style>
                                            <contents>
                                                <textItem>
                                                    <dataSource>
                                                        <staticValue>Retailer Type</staticValue>
                                                    </dataSource>
                                                </textItem>
                                            </contents>
                                        </listColumnTitle>
                                        <listColumnBody>
                                            <style>
                                                <defaultStyles>
                                                    <defaultStyle refStyle="lc"/>
                                                </defaultStyles>
                                            </style>
                                            <contents>
                                                <repeaterTable across="20" down="1" name="Repeater table1" refQuery="Query2">
                                                    <repeaterTableCell>
                                                        <contents>
                                                            <textItem>
                                                                <dataSource>
                                                                    <dataItemValue refDataItem="Retailer type"/>
                                                                </dataSource>
                                                            </textItem>
                                                            <textItem>
                                                                <dataSource>
                                                                    <dataItemValue refDataItem="Comma"/>
                                                                </dataSource>
                                                            </textItem>
                                                        </contents>
                                                        <style>
                                                            <defaultStyles>
                                                                <defaultStyle refStyle="rc"/>
                                                            </defaultStyles>
                                                            <CSS value="padding:0px;font-size:8pt"/>
                                                        </style>
                                                    </repeaterTableCell>
                                                    <style>
                                                        <CSS value="border-collapse:collapse"/>
                                                        <defaultStyles>
                                                            <defaultStyle refStyle="rt"/>
                                                        </defaultStyles>
                                                    </style>
                                                    <masterDetailLinks>
                                                        <masterDetailLink>
                                                            <masterContext>
                                                                <dataItemContext refDataItem="Country"/>
                                                            </masterContext>
                                                            <detailContext>
                                                                <dataItemContext refDataItem="Country"/>
                                                            </detailContext>
                                                        </masterDetailLink>
                                                    </masterDetailLinks>
                                                </repeaterTable>
                                            </contents>
                                        </listColumnBody>
                                    </listColumn>
                                    <listColumn>
                                        <listColumnTitle>
                                            <style>
                                                <defaultStyles>
                                                    <defaultStyle refStyle="lt"/>
                                                </defaultStyles>
                                            </style>
                                            <contents>
                                                <textItem>
                                                    <dataSource>
                                                        <dataItemLabel refDataItem="Quantity"/>
                                                    </dataSource>
                                                </textItem>
                                            </contents>
                                        </listColumnTitle>
                                        <listColumnBody>
                                            <style>
                                                <defaultStyles>
                                                    <defaultStyle refStyle="lm"/>
                                                </defaultStyles>
                                            </style>
                                            <contents>
                                                <textItem>
                                                    <dataSource>
                                                        <dataItemValue refDataItem="Quantity"/>
                                                    </dataSource>
                                                </textItem>
                                            </contents>
                                        </listColumnBody>
                                    </listColumn>
                                </listColumns>
                                <listOverallGroup>
                                    <listFooter>
                                        <listRows>
                                            <listRow>
                                                <rowCells>
                                                    <rowCell colSpan="2">
                                                        <contents>
                                                            <textItem>
                                                                <dataSource>
                                                                    <staticValue>Overall</staticValue>
                                                                </dataSource>
                                                            </textItem>
                                                            <textItem>
                                                                <dataSource>
                                                                    <staticValue> - </staticValue>
                                                                </dataSource>
                                                            </textItem>
                                                            <textItem>
                                                                <dataSource>
                                                                    <staticValue>Summary</staticValue>
                                                                </dataSource>
                                                            </textItem>
                                                        </contents>
                                                        <style>
                                                            <defaultStyles>
                                                                <defaultStyle refStyle="if"/>
                                                            </defaultStyles>
                                                        </style>
                                                    </rowCell>
                                                    <rowCell>
                                                        <contents>
                                                            <textItem>
                                                                <dataSource>
                                                                    <dataItemValue refDataItem="Summary(Quantity)"/>
                                                                </dataSource>
                                                            </textItem>
                                                        </contents>
                                                        <style>
                                                            <defaultStyles>
                                                                <defaultStyle refStyle="is"/>
                                                            </defaultStyles>
                                                        </style>
                                                    </rowCell>
                                                </rowCells>
                                            </listRow>
                                        </listRows>
                                    </listFooter>
                                </listOverallGroup>
                            </list>
                        </contents>
                    </pageBody>
                </page>
            </reportPages>
        </layout>
    </layouts>
    <XMLAttributes>
        <XMLAttribute output="no" name="RS_CreateExtendedDataItems" value="true"/>
        <XMLAttribute output="no" name="listSeparator" value=","/>
    </XMLAttributes>
    <modelPath>/content/folder[@name=&apos;Samples&apos;]/folder[@name=&apos;Models&apos;]/package[@name=&apos;GO sales (query)&apos;]/model[@name=&apos;model&apos;]</modelPath>
    <queries>
        <query name="Query1">
            <source>
                <model/>
            </source>
            <selection>
                <dataItem aggregate="none" rollupAggregate="none" name="Country" sort="ascending">
                    <expression>[Sales (query)].[Branch].[Country]</expression>
                    <XMLAttributes>
                        <XMLAttribute output="no" name="RS_dataType" value="3"/>
                        <XMLAttribute output="no" name="RS_dataUsage" value="attribute"/>
                    </XMLAttributes>
                </dataItem>
                <dataItem aggregate="none" rollupAggregate="none" name="Retailer type" sort="ascending">
                    <expression>[Sales (query)].[Retailer type].[Retailer type]</expression>
                    <XMLAttributes>
                        <XMLAttribute output="no" name="RS_dataType" value="3"/>
                        <XMLAttribute output="no" name="RS_dataUsage" value="attribute"/>
                    </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="fact"/>
                    </XMLAttributes>
                </dataItem>
                <dataItemListSummary refDataItem="Quantity" aggregateMethod="aggregate" name="Summary(Quantity)"/>
            </selection>
            <detailFilters>
                <detailFilter>
                    <filterExpression>[Sales (query)].[Time].[Year] = 2013</filterExpression>
                </detailFilter>
            </detailFilters>
        </query>
        <query name="Query2">
            <source>

                <queryRef refQuery="Query1"/>
            </source>
            <selection>
                <dataItem aggregate="none" rollupAggregate="none" name="Country">
                    <expression>[Query1].[Country]</expression>
                </dataItem>
                <dataItem aggregate="none" rollupAggregate="none" name="Retailer type">
                    <expression>[Query1].[Retailer type]</expression>
                    <XMLAttributes>
                        <XMLAttribute output="no" name="RS_dataType" value="3"/>
                        <XMLAttribute output="no" name="RS_dataUsage" value="0"/>
                    </XMLAttributes>
                </dataItem>
                <dataItem name="Comma">
                    <expression>case
    when running-count ([Retailer type] for [Country]) &lt; maximum (running-count ([Retailer type] for [Country]) for [Country]) then &apos;,&apos;
    else &apos;&apos;
end</expression>
                    <XMLAttributes>
                        <XMLAttribute output="no" name="RS_dataType" value="3"/>
                        <XMLAttribute output="no" name="RS_dataUsage" value=""/>
                    </XMLAttributes>
                </dataItem>
            </selection>
        </query>
        <query name="Query3">
            <source>

                <queryRef refQuery="Query1"/>
            </source>
            <selection>
                <dataItemListSummary aggregateMethod="aggregate" name="Summary(Quantity)" refDataItem="Quantity"/>
                <dataItem aggregate="none" rollupAggregate="none" name="Country">
                    <expression>[Query1].[Country]</expression>
                    <XMLAttributes>
                        <XMLAttribute output="no" name="RS_dataType" value="3"/>
                        <XMLAttribute output="no" name="RS_dataUsage" value="0"/>
                    </XMLAttributes>
                </dataItem>
                <dataItem aggregate="total" name="Quantity">
                    <expression>[Query1].[Quantity]</expression>
                    <XMLAttributes>
                        <XMLAttribute output="no" name="RS_dataType" value="2"/>
                        <XMLAttribute output="no" name="RS_dataUsage" value="2"/>
                    </XMLAttributes>
                </dataItem>
            </selection>
        </query>
    </queries>
    <reportName>Repeater Table (using Samples data)</reportName>
</report>

使用转发器table 简单的查询结构。这将为每个值(之前或之后)创建一个逗号,并且无法在第一个值之前或最后一个值之后省略逗号。

这是一份示例报告:

你没有说 Cognos 是什么版本。这是针对 11.0.13 的。您可能需要更新第一行中的版本号和样式版本以匹配您的环境。

<report xmlns="http://developer.cognos.com/schemas/report/14.3/" useStyleVersion="11.4" expressionLocale="en-us">
    <drillBehavior/>
    <layouts>
        <layout>
            <reportPages>
                <page name="Page1">
                    <style>
                        <defaultStyles>
                            <defaultStyle refStyle="pg"/>
                        </defaultStyles>
                    </style>
                    <pageBody>
                        <style>
                            <defaultStyles>
                                <defaultStyle refStyle="pb"/>
                            </defaultStyles>
                        </style>
                        <contents>
                            <list horizontalPagination="true" name="List1" refQuery="Query1">
                                <noDataHandler>
                                    <contents>
                                        <block>
                                            <contents>
                                                <textItem>
                                                    <dataSource>
                                                        <staticValue>No Data Available</staticValue>
                                                    </dataSource>
                                                    <style>
                                                        <CSS value="padding:10px 18px;"/>
                                                    </style>
                                                </textItem>
                                            </contents>
                                        </block>
                                    </contents>
                                </noDataHandler>
                                <style>
                                    <CSS value="border-collapse:collapse"/>
                                    <defaultStyles>
                                        <defaultStyle refStyle="ls"/>
                                    </defaultStyles>
                                </style>
                                <listColumns>
                                    <listColumn>
                                        <listColumnTitle>
                                            <style>
                                                <defaultStyles>
                                                    <defaultStyle refStyle="lt"/>
                                                </defaultStyles>
                                            </style>
                                            <contents>
                                                <textItem>
                                                    <dataSource>
                                                        <dataItemLabel refDataItem="Country"/>
                                                    </dataSource>
                                                </textItem>
                                            </contents>
                                        </listColumnTitle>
                                        <listColumnBody>
                                            <style>
                                                <defaultStyles>
                                                    <defaultStyle refStyle="lc"/>
                                                </defaultStyles>
                                            </style>
                                            <contents>
                                                <textItem>
                                                    <dataSource>
                                                        <dataItemValue refDataItem="Country"/>
                                                    </dataSource>
                                                </textItem>
                                            </contents>
                                        </listColumnBody>
                                    </listColumn>
                                    <listColumn>
                                        <listColumnTitle>
                                            <style>
                                                <defaultStyles>
                                                    <defaultStyle refStyle="lt"/>
                                                </defaultStyles>
                                            </style>
                                            <contents>
                                                <textItem>
                                                    <dataSource>
                                                        <staticValue>Retailer Type</staticValue>
                                                    </dataSource>
                                                </textItem>
                                            </contents>
                                        </listColumnTitle>
                                        <listColumnBody>
                                            <style>
                                                <defaultStyles>
                                                    <defaultStyle refStyle="lc"/>
                                                </defaultStyles>
                                            </style>
                                            <contents>
                                                <repeaterTable name="Repeater table1" refQuery="Query1" across="20" down="1">
                                                    <repeaterTableCell>
                                                        <contents>
                                                            <textItem>
                                                                <dataSource>
                                                                    <dataItemValue refDataItem="Retailer type"/>
                                                                </dataSource>
                                                            </textItem>
                                                            <textItem>
                                                                <dataSource>
                                                                    <staticValue>, </staticValue>
                                                                </dataSource>
                                                            </textItem>
                                                        </contents>
                                                        <style>
                                                            <defaultStyles>
                                                                <defaultStyle refStyle="rc"/>
                                                            </defaultStyles>
                                                            <CSS value="padding:0px;font-size:8pt"/>
                                                        </style>
                                                    </repeaterTableCell>
                                                    <style>
                                                        <CSS value="border-collapse:collapse"/>
                                                        <defaultStyles>
                                                            <defaultStyle refStyle="rt"/>
                                                        </defaultStyles>
                                                    </style>
                                                    <masterDetailLinks>
                                                        <masterDetailLink>
                                                            <masterContext>
                                                                <dataItemContext refDataItem="Country"/>
                                                            </masterContext>
                                                            <detailContext>
                                                                <dataItemContext refDataItem="Country"/>
                                                            </detailContext>
                                                        </masterDetailLink>
                                                    </masterDetailLinks>
                                                </repeaterTable>
                                            </contents>
                                        </listColumnBody>
                                    </listColumn>
                                    <listColumn>
                                        <listColumnTitle>
                                            <style>
                                                <defaultStyles>
                                                    <defaultStyle refStyle="lt"/>
                                                </defaultStyles>
                                            </style>
                                            <contents>
                                                <textItem>
                                                    <dataSource>
                                                        <dataItemLabel refDataItem="Quantity"/>
                                                    </dataSource>
                                                </textItem>
                                            </contents>
                                        </listColumnTitle>
                                        <listColumnBody>
                                            <style>
                                                <defaultStyles>
                                                    <defaultStyle refStyle="lm"/>
                                                </defaultStyles>
                                            </style>
                                            <contents>
                                                <textItem>
                                                    <dataSource>
                                                        <dataItemValue refDataItem="Quantity"/>
                                                    </dataSource>
                                                </textItem>
                                            </contents>
                                        </listColumnBody>
                                    </listColumn>
                                </listColumns>
                                <listOverallGroup>
                                    <listFooter>
                                        <listRows>
                                            <listRow>
                                                <rowCells>
                                                    <rowCell colSpan="2">
                                                        <contents>
                                                            <textItem>
                                                                <dataSource>
                                                                    <staticValue>Overall</staticValue>
                                                                </dataSource>
                                                            </textItem>
                                                            <textItem>
                                                                <dataSource>
                                                                    <staticValue> - </staticValue>
                                                                </dataSource>
                                                            </textItem>
                                                            <textItem>
                                                                <dataSource>
                                                                    <staticValue>Summary</staticValue>
                                                                </dataSource>
                                                            </textItem>
                                                        </contents>
                                                        <style>
                                                            <defaultStyles>
                                                                <defaultStyle refStyle="if"/>
                                                            </defaultStyles>
                                                        </style>
                                                    </rowCell>
                                                    <rowCell>
                                                        <contents>
                                                            <textItem>
                                                                <dataSource>
                                                                    <dataItemValue refDataItem="Summary(Quantity)"/>
                                                                </dataSource>
                                                            </textItem>
                                                        </contents>
                                                        <style>
                                                            <defaultStyles>
                                                                <defaultStyle refStyle="is"/>
                                                            </defaultStyles>
                                                        </style>
                                                    </rowCell>
                                                </rowCells>
                                            </listRow>
                                        </listRows>
                                    </listFooter>
                                </listOverallGroup>
                            </list>
                        </contents>
                    </pageBody>
                </page>
            </reportPages>
        </layout>
    </layouts>
    <XMLAttributes>
        <XMLAttribute output="no" name="RS_CreateExtendedDataItems" value="true"/>
        <XMLAttribute output="no" name="RS_modelModificationTime" value="2015-11-25T21:38:24.820Z"/>
        <XMLAttribute output="no" name="listSeparator" value=","/>
    </XMLAttributes>
    <modelPath>/content/folder[@name=&apos;Samples&apos;]/folder[@name=&apos;Models&apos;]/package[@name=&apos;GO sales (query)&apos;]/model[@name=&apos;model&apos;]</modelPath>
    <queries>
        <query name="Query1">
            <source>
                <model/>
            </source>
            <selection>
                <dataItem aggregate="none" rollupAggregate="none" name="Country" sort="ascending">
                    <expression>[Sales (query)].[Branch].[Country]</expression>
                    <XMLAttributes>
                        <XMLAttribute output="no" name="RS_dataType" value="3"/>
                        <XMLAttribute output="no" name="RS_dataUsage" value="attribute"/>
                    </XMLAttributes>
                </dataItem>
                <dataItem aggregate="none" rollupAggregate="none" name="Retailer type" sort="ascending">
                    <expression>[Sales (query)].[Retailer type].[Retailer type]</expression>
                    <XMLAttributes>
                        <XMLAttribute output="no" name="RS_dataType" value="3"/>
                        <XMLAttribute output="no" name="RS_dataUsage" value="attribute"/>
                    </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="fact"/>
                    </XMLAttributes>
                </dataItem>
                <dataItemListSummary refDataItem="Quantity" aggregateMethod="aggregate" name="Summary(Quantity)"/>
            </selection>
            <detailFilters>
                <detailFilter>
                    <filterExpression>[Sales (query)].[Time].[Year] = 2013</filterExpression>
                </detailFilter>
            </detailFilters>
        </query>
    </queries>
    <reportName>Repeater Table (simple - using Samples data)</reportName>
</report>