Jump to content

BIRT Developer Center Download


Submitter

File Information

  • Submitted: Jul 02 2013 06:37 AM
  • Last Updated: Apr 30 2014 06:30 AM
  • File Size: 3.57KB
  • Views: 16991
  • Downloads: 91
  • Approved by: kclark
  • Approved on: 30 April 2014 - 06:31 AM
  • Summary: An example showing how to transpose columns in a dataset to rows
  • Content Type: Designs & Code
  • BIRT Version: 3.7

Download Transposed data sets

- - - - -
Data Sets Transpose Column Table



Screenshots
Sometimes it is useful to convert columnar data of the form:
Key1 Value1 Value2 Value3 Value4 etc... A 1 2 3 4 B 5 6 7 8

...to row data in the form
Key1 Category Value A Value1 1 A Value2 2 A Value3 3 A Value4 4 B Value1 5 B Value2 6 B Value3 7 B Value4 8 etc...

This can be particularly useful for charts and crosstabs when the data is not in the format you need.

It's also useful if you want to get the field names into data rows.

The attached library contains helper components to achieve just this.

Extend CachedDataSet in your report to select the data that needs transposing (don't worry that it shows an error in the library; this is because it is not associated with a data source until you use it). Make sure that the columns you want transposing come last and note how many columns there are that should be copied to each row. In the above example there is one fixed column, Key1, which is repeated in each transposed row.

Extend TransposedDataSet in your report to get the transposed data. Transposed data is written to the Category and Value columns. The library defaults to one fixed output column but you can rename it in your subclass.

If you have more than one fixed output column you should to add output columns to the data set for each of your fixed columns. Make sure these come in the same order as the CachedDataSet and are first in the list of output columns ahead of the Category and value fields. You should also override the Open script on your subclassed TransposedDataSet and update the number of fixed columns.




Photo
prashantshrivas
Dec 18 2014 01:19 AM

Thanks for the solution. I am trying to implement the same in my template but it seems the script is not getting executed. How do I upload my template here for your input?




1 user(s) are online (in the past 1 minutes)

0 members, 1 guests, 0 anonymous users