Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Help, best way to gruop
Frenkys
I use Birt 2.6.2 and I have a dataset like this:
Job1 Job2 Job3 Job4
+
+
+
Mary Mary John Gilbert
Richard Helen John Helen
Mary Helen Cindy Cindy
Mary Mary Mary Mary
Richard John Helen Helen
Mary Cindy Cindy Richard
Mary Cindy Mary Helen
Richard John Helen Mary
Mary Cindy Helen Helen
? ? ? ?
What is the best way to group, count and get a report like this?
User Job1 Job2 Job3 Job4
+
+
+
+
Mary 6 2 2 2
Richard 3 0 0 1
Helen 0 2 2 4
Cindy 0 3 2 1
Gilbert 0 0 0 1
John 0 2 2 0
.... ... ... ... ...
Some users may only be present in a column.
Thanks
Find more posts tagged with
Comments
Hans_vd
Hi Frenkys,<br />
<br />
Write your SQL like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>SELECT 'job1' AS job,
job1 AS employee
FROM jobs
UNION ALL
SELECT 'job2' AS job,
job2 AS employee
FROM jobs
UNION ALL
SELECT 'job3' AS job,
job3 AS employee
FROM jobs
UNION ALL
SELECT 'job4' AS job,
job4 AS employee
FROM jobs</pre>
<br />
Then create a crosstab with two dimensions: job and employee, and 1 measure count(job) (or count(employee), both will work)<br />
<br />
Regards<br />
Hans
Frenkys
<blockquote class='ipsBlockquote' data-author="'Hans_vd'" data-cid="107665" data-time="1343657778" data-date="30 July 2012 - 07:16 AM"><p>
Hi Frenkys,<br />
<br />
Write your SQL like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>SELECT 'job1' AS job,
job1 AS employee
FROM jobs
UNION ALL
SELECT 'job2' AS job,
job2 AS employee
FROM jobs
UNION ALL
SELECT 'job3' AS job,
job3 AS employee
FROM jobs
UNION ALL
SELECT 'job4' AS job,
job4 AS employee
FROM jobs</pre>
<br />
Then create a crosstab with two dimensions: job and employee, and 1 measure count(job) (or count(employee), both will work)<br />
<br />
Regards<br />
Hans<br /></p></blockquote>
<br />
Hi Hans,<br />
Thanks for the answer, but there is a way without changing my sql?<br />
This dataset is only an example; my dataset is the result of a query with many other data.<br />
Thanks
Hans_vd
I don't immediately see another solution.
But I'm gonna take another look at it.
Hans_vd
Hi Frenkys,
I've been thinking about it and I'm quite sure that there is no possibility to group the users as long as they are in a two dimensional structure in your dataset.
Is it really that hard to modify your query?
Is the way you have the users in 4 different columns the result of how the query is built, or are they in the database that way?
Regards
Hans
Frenkys
<blockquote class='ipsBlockquote' data-author="'Hans_vd'" data-cid="107688" data-time="1343717531" data-date="30 July 2012 - 11:52 PM"><p>
...<br />
Is the way you have the users in 4 different columns the result of how the query is built, or are they in the database that way?<br />
<br />
Regards<br />
Hans<br /></p></blockquote>
<br />
They are in the database that way.<br />
Maybe I can add a new dataset only to do what you suggest.<br />
<br />
Regards