问题
I have a set of data which right now I have in a List. It looks something like this (sample data obviously)
Event ID | Field Name | Value
-------------------------------------
EV123 | Name | John
EV456 | Name | Karen
EV789 | Name | Bob
EV123 | City | New York
EV456 | City | Chicago
EV789 | City | Los Angeles
EV123 | State | NY
EV456 | State | IL
EV789 | State | CA
The Event ID and Field name values are all unique - for each combination of Event and Field Name there is only 1 row. There are about 50 Field Names and they will change from time to time.
I'm trying to do a cross-tab or other similar layout to instead show the data laid out as such:
Event ID | Name | City | State
---------------------------------------------------
EV123 | John | New York | NY
EV456 | Karen | Chicago | IL
EV789 | Bob | Los Angeles | CA
I have tried doing a cross-tab in Cognos which properly shows the columns across the top row and the Event IDs along the first column, however even when I drag the "Value" column into the section where I expect to see data, nothing is showing. I think this is because it's trying to sum or aggregate the data which isn't numeric.
How can I achieve the layout I'm trying to go for here? Please keep in mind that I am a Cognos newbie and don't have a great knowledge of SQL, so the more guidance you can provide the better!
Thank you in advance.
回答1:
Here are the steps to add a non-numeric column to the measure area of a crosstab:
- Drag over a Crosstab Space object from the toolbox and drop it on the column header section just to the right of the last column
- Select the empty fact cells under the new crosstab space
- Set the ‘Define Contents’ property to ‘Yes’
- Unlock the report
- Drag over the non-numeric data item either from a model or an existing query and drop it in the empty fact cells
- Click on and highlight the right-most row header item
- Click on the ellipsis in the ‘Properties’ property to bring up the ‘Properties’ dialog box
- Check the data item corresponding to your newly-added non-measure column and click ‘OK’
- Configure a header label for the new column. This can be done by either dragging over a text item and manually entering the name or via the ‘Source Type and ‘Data Item Label’ properties.
来源:https://stackoverflow.com/questions/52101741/cross-tabulate-non-numeric-data-in-cognos-bi