Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Transpose rows into columns.
gopi.inampudi
<p>Hi Guys,</p>
<p> </p>
<p>I need to convert the data like below by using Actuate.</p>
<p> </p>
<p>Either in iob level or Report level. Kinldy help us to achieve this. </p>
<p> </p>
<p>Source</p>
<p>
</p>
<p>col1, col2</p>
<p>1,10</p>
<p>1,20</p>
<p>1,30</p>
<p>2,10</p>
<p>2,40</p>
<p>3,70</p>
<p>3,60</p>
<p>3,10</p>
<p> </p>
<p>Target</p>
<p>
</p>
<p>col1, col2, col3, col4, col5</p>
<p> 1 10 20 30 40</p>
<p> 2 10 40</p>
<p> 3 70 60 10</p>
<p> </p>
<p> </p>
<p>--</p>
<p>Thanks & Regards,</p>
<p>Gopi</p>
Find more posts tagged with
Comments
JFreeman
<p>You could manually iterate over your data set and dynamically add columns to a table.</p>
<p> </p>
<p>Here is an example of dynamic table/columns that will help get you started: <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/24254-creating-column-dynamically/?p=132987'>http://developer.actuate.com/community/forum/index.php?/topic/24254-creating-column-dynamically/?p=132987</a></p>
;
<p> </p>
<p>EDIT: More Examples: <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/36942-scripted-dataset-to-parse-a-dynamic-xml-string/?p=137936'>http://developer.actuate.com/community/forum/index.php?/topic/36942-scripted-dataset-to-parse-a-dynamic-xml-string/?p=137936</a></p>
;
datakeywor
<p>Group records by col1, and then create an empty table according to "the maximum number of recorders in each group plus 1". To perform the transposition , loop through each group to append data to the empty table. It's pretty hard to do this with the stored procedure, but you can make it in esProc using the following the code:</p>
<p> </p>
<p>A1= select col1,col2 from tb</p>
<p>A2= A1.group(col1)</p>
<p>A3= create(${(A2.max(~.count())+1).("col1"+string(~)).string()})</p>
<p>A4> A2.run(A3.record(~.col1|~.(col2)))</p>
<p> </p>
<p>In practice , the column names of the new two-dismentional table are usually the values in col2(rather than the meaningless name such as col1 and col2). Find more transposition examples from <a data-ipb='nomediaparse' href='
http://blog.raqsoft.com/?p=4962'>http://blog.raqsoft.com/?p=4962</a>
. BIRT can access the esProc script via jdbc, and refer to <a data-ipb='nomediaparse' href='
http://blog.raqsoft.com/?p=4665'>http://blog.raqsoft.com/?p=4665</a>
; to know more about this.</p>
PaulCooper
<p>Another way would be to add a row_id column to the SQL:</p>
<pre class="_prettyXprint">
row_number() over (partition by col1 order by <original ordering fields>) "column_id"</pre>
<p>Replace <em><original ordering fields></em> with the appropriate fields.</p>
<p> </p>
<p>Then use a crosstab in the report with "column_id" as your top grouping and col1 as your left grouping.</p>
<p> </p>
<p>You may not want 1, 2, 3, etc as column headings so you may want to hide this field and create a field that maps the number to the headings you want.</p>