Cognos analytics multiple measures in a single cell - analytics

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.

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>

Related

I can't change range and/or default values in DevExpress Dashboard

I have a page where users register and can make their personal diet plan etc.
I am trying to make some graphs with built-in VS dashboards.
I am using VS 2015 and SQL Server Management Studio 15.0.18206.0 if that matters.
My problems are the following:
Automatic (SUM)
Dashboard values default to SUM function, which I am not able to change, as you see in the first picture, but I kind of managed to solve this problem with the help of SQL (SELECT DISTINCT, SELECT TOP(1) etc.)
Automatic (SUM)
Default year count
When I am trying to make a dashboard to show track of user's vitals and activity, which is the core of my statistics, time defaults to YEAR and the result end up like the second picture.
Default year count
There is nothing I can do to change these and I just made irrelevant graphs to fill the page, but it's a shame because I planned to make a lot of graphs with the table you see in the third picture.
User History table
If it helps, the XML code generated from the last dashboard is this:
<?xml version="1.0" encoding="utf-8"?>
<Dashboard>
<Title Text="YearDashBoard" />
<DataSources>
<SqlDataSource ComponentName="DataSource1">
<Name>UserHistory1</Name>
<Connection Name="foodConnectionString" FromAppConfig="true" />
<Query Type="SelectQuery" Name="UserHistory1" Distinct="true">
<Tables>
<Table Name="UserHistory" />
</Tables>
<Columns>
<Column Table="UserHistory" Name="CaloriesDate" />
<Column Table="UserHistory" Name="DailyCalories" />
<Column Table="UserHistory" Name="UserID" />
</Columns>
<Filter>[UserHistory.UserID] = 17</Filter>
</Query>
<ConnectionOptions CloseConnection="true" CommandTimeout="0" />
</SqlDataSource>
</DataSources>
<Items>
<Chart ComponentName="chartDashboardItem1" Name="Chart 1" DataSource="DataSource1" DataMember="UserHistory1">
<DataItems>
<Measure DataMember="DailyCalories" DefaultId="DataItem0" />
<Dimension DataMember="CaloriesDate" DefaultId="DataItem1" />
</DataItems>
<Arguments>
<Argument DefaultId="DataItem1" />
</Arguments>
<Panes>
<Pane Name="Pane 1">
<Series>
<Simple>
<Value DefaultId="DataItem0" />
</Simple>
</Series>
</Pane>
</Panes>
</Chart>
</Items>
<LayoutTree>
<LayoutGroup Weight="100">
<LayoutItem DashboardItem="chartDashboardItem1" Weight="100" />
</LayoutGroup>
</LayoutTree>
</Dashboard>
Finally, with the help of DevExpress technical team, I found out that the whole time there was an invisible scroll bar, but you had to mouse over it (!) while being on the "BINDING" tab of the menu.

How to publish additional postgis raster layer attributes in geoserver?

i was wondering if any of You can help me with my problem. I'm storing some rasters in Postgis database. Each raster is in its own table and besides 'rid' and 'rast' columns, I manualy added other columns to store raster attributes such as 'metadata'...
I have successfully imported rasters in geoserver using ImageMosaic JDBC and in Layers Preview (OpenLayers) I can see rasters and use getFeatureInfo function, but the problem is that function getFeatureInfo returns table with correct pixel value , 'rid' field is empty (only table header apears) and no other attribute is shown (not even attribute header in table). I'm using default geoserver method for layer preview function.
mapping.postgis.xml.inc file
<!-- possible values: universal,postgis,db2,mysql,oracle -->
<spatialExtension name="pgraster"/>
<mapping>
<masterTable name="mosaic" >
<coverageNameAttribute name="name"/>
<maxXAttribute name="maxx"/>
<maxYAttribute name="maxy"/>
<minXAttribute name="minx"/>
<minYAttribute name="miny"/>
<resXAttribute name="resx"/>
<resYAttribute name="resy"/>
<tileTableNameAtribute name="tiletable" />
</masterTable>
<tileTable>
<blobAttributeName name="rast" />
<keyAttributeName name="rid" />
<textAttributeName name="metadata" />
</tileTable>
</mapping>
connect.postgis.xml.inc
<connect>
<!-- value DBCP or JNDI -->
<dstype value="DBCP"/>
<!-- <jndiReferenceName value=""/> -->
<username value="postgres" />
<password value="postgres" />
<jdbcUrl value="jdbc:postgresql://localhost:5432/web_kartografija" />
<driverClassName value="org.postgresql.Driver"/>
<maxActive value="10"/>
<maxIdle value="0"/>
</connect>
layer.postgis.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE ImageMosaicJDBCConfig [
<!ENTITY mapping PUBLIC "mapping" "mapping.postgis.xml.inc">
<!ENTITY connect PUBLIC "connect" "connect.postgis.xml.inc">]>
<config version="1.0">
<coverageName name="jan"/> <!-- Name of the table in database -->
<coordsys name="EPSG:4326"/>
<!-- interpolation 1 = nearest neighbour, 2 = bilinear, 3 = bicubic -->
<scaleop interpolation="1"/>
<verify cardinality="false"/>
&mapping;
&connect;
</config>
I tried to include <textAttributeName name="metadata" /> as a column name where aditional data is stored, but still no effect. Can anobudy help me with this problem ? Thanks in advance !

mapnik not rendering postgis multipolygonzm?

So I loaded a bunch of NHD data, and the geometry ended up as MultiPolygonZM (and pointZM and areaZM for other tables)
way geometry(MultiPolygonZM,900913)
I've tested the query and its returning data when run against the db directly. Here's my style:
<Style name="waterways">
<Rule>
<LineSymbolizer stroke="blue" stroke-width="3" />
</Rule>
</Style>
<Layer name="waterways" status="on">
<StyleName>waterways</StyleName>
<Datasource>
<Parameter name="table">
(select way
from nhd_waterbody)
as waterway
</Parameter>
<Parameter name="type">postgis</Parameter>
<Parameter name="port">5432</Parameter>
<Parameter name="user">gisuser</Parameter>
<Parameter name="dbname">gis</Parameter>
<Parameter name="estimate_extent">false</Parameter>
<Parameter name="extent">-20037508,-19929239,20037508,19929239</Parameter>
</Datasource>
</Layer>
But I can't get mapnik (version 2.10) to render it. The osm data is rendering just fine (its standard MultiPolygon, not 4d) from mapnik and qgis (v1.8) map all of it just hunky dory. Has anyone else experienced anything like this? Is it a geometry problem or is that just a red herring? Is there anyway to get mapnik to spit out any type of debug info when rendering?
TIA!
-- Randy
Several GIS programs, such as QGIS, internally use ST_Force_2D to make a 2D drawing from higher-dimension data types. I'm not sure how Mapnik treats these geometries, but I suspect they might not be supported. Also, be sure to double-check the extent, since this is often overlooked.
If you are not actually using the higher dimensions, then remove them! For PostGIS 2.0:
ALTER TABLE my_table
ALTER COLUMN way TYPE geometry(MultiPolygon,900913) USING ST_Force_2D(way);
And for PostGIS 1.x, see this answer.

Jasper Report (iReport) Pie Dataset from main dataset

I want to use a pie chart per group in Jasper iReport, but I don't know how to create a dataset per group.
Assume I have a table as follows:
Table users
---------
category - user - status
Then I have a the following SQL
select * from users order by category
My display has a simple group band of category with detail showing each user and their status. Ideally I would have each category group header show a pie chart with all the distinct statuses and their counts within that group. I'm at a loss as how to do this in iReport.
If I knew all the categories ahead of time I could just create a dataset for each one using the following:
select status, count(user) from user where category = <current category> group by status
I'm attempting to do this using a JRMapCollectionDataSource that resets each group and pulls the data from the rows in the group using a variable, but I'm not very familiar with the whole reset group and increment paradigm.
Any help?
You can solve this issue without programming following this steps:
sort data by category field and by user field (add sorting via iReport or adding ORDER BY clause to the query in case having deal with jdbc datasource);
add two groups: the 1st group - for category field and the 2nd group - for user field (via iReport). Note: It is not necessarily to add GROUP BY clause to the query;
add Pie Chart component to the Group Header band for the category field;
set evaluationTime and evaluationGroup properties for this pieChart.
Here is working sample for demonstrating how to build Pie Chart. In this sample I've used the csv file as datasource.
The chart shows the quantity of users for every category. I used variable usersCount for counting users in every group, but it is was possible to use built-in variable $V{userGroup_COUNT}.
Here is my jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ...>
<field name="category" class="java.lang.Integer"/>
<field name="user" class="java.lang.String"/>
<field name="status" class="java.lang.String"/>
<sortField name="category"/>
<sortField name="user"/>
<variable name="usersCount" class="java.lang.Integer" resetType="Group" resetGroup="userGroup" calculation="Count">
<variableExpression><![CDATA[$F{user}]]></variableExpression>
<initialValueExpression><![CDATA[0]]></initialValueExpression>
</variable>
<group name="categoryGroup">
<groupExpression><![CDATA[$F{category}]]></groupExpression>
<groupHeader>
<band height="135">
<pieChart>
<chart evaluationTime="Group" evaluationGroup="categoryGroup">
<reportElement x="158" y="0" width="200" height="135"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset>
<dataset resetType="Group" resetGroup="categoryGroup" incrementType="Group" incrementGroup="userGroup"/>
<keyExpression><![CDATA[$F{user}]]></keyExpression>
<valueExpression><![CDATA[$V{usersCount}]]></valueExpression>
<labelExpression><![CDATA[String.valueOf($V{usersCount})]]></labelExpression>
</pieDataset>
<piePlot>
<plot/>
<itemLabel/>
</piePlot>
</pieChart>
<textField>
<reportElement x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA["Category: " + $F{category}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
</group>
<group name="userGroup">
<groupExpression><![CDATA[$F{user}]]></groupExpression>
</group>
<title>
<band height="79" splitType="Stretch"/>
</title>
</jasperReport>
Here is my csv file (data file - datasource):
category,user,status
1,user1,WORK
1,user1,HOLIDAY
1,user2,SICK
2,user1,WORK
2,user2,WORK
2,user2,HOLIDAY
2,user3,HOLIDAY
2,user4,SICK
3,user1,HOLIDAY
3,user3,HOLIDAY
3,user5,HOLIDAY
4,user1,WORK
4,user1,HOLIDAY
4,user2,SICK
4,user2,WORK
4,user2,SICK
4,user3,HOLIDAY
4,user4,HOLIDAY
4,user5,HOLIDAY
The result will be (via iReport preview):

iReport, how to print fields of different table

I need multiple queries in my report so i added a new dataset.
The problem is i can't use fields of new dataset in my report, the error is: field does not exists.
So, how can i have multiple query in my report(to print fields of different table) without create a subreport for each field?
Thanks.
Unfortunately this isn't how iReport works. You need to get all your data into one dataset to use the fields side by side. See #GenericJon's detailed answer on using a datasetRun where your fields are used as input parameters to define another dataset.
If you really want the parameters can be used to pass a field for output in a datasetRun. This outputs Dataset1>Field1 / Dataset2>Field2.
<subDataset name="TotalUsers">
<parameter name="Users" class="java.lang.Integer" isForPrompting="false"/>
<parameter name="Date" class="java.util.Date" isForPrompting="false"/>
<queryString language="SQL">
<![CDATA[CALL GetTotalUsersAtDate($P{Date})]]>
</queryString>
<field name="TotalUsers" class="java.lang.Long"/>
</subDataset>
...
<componentElement>
<reportElement x="0" y="78" width="555" height="16"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="TotalUsers">
<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
<datasetParameter name="Users">
<datasetParameterExpression><![CDATA[$F{MusicSubscribers}]]></datasetParameterExpression>
</datasetParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:listContents height="16" width="555">
<textField pattern="#,##0.00 %" isBlankWhenNull="true">
<reportElement style="table_TD" x="475" y="0" width="80" height="16"/>
<textElement/>
<textFieldExpression><![CDATA[$P{Users}.doubleValue()/$F{TotalUsers}.doubleValue()]]></textFieldExpression>
</textField>
<staticText>
<reportElement style="table_TD" x="0" y="0" width="475" height="16"/>
<textElement textAlignment="Left" markup="none"/>
<text><![CDATA[Proportion of total users]]></text>
</staticText>
</jr:listContents>
</jr:list>
</componentElement>
I would go further to suggest you do as much of the math and collating outside of iReport too, i.e. use stored procedures if your data source is a database.

Resources