dynamo
dynamo

Reputation: 1153

Birt Report with Dynamic Column

I want to create a Birt table report with dynamic number of columns from xml datasource. How can I go about it ?

While searching I have read that it can be done with scripted datasource but I couldn't find example or documentation of how to use scripted datasource with xml datasource.

I have also tried cross tab which only seems to work if there is some form aggregation (it doesn't work with strings).

Here is a sample xml:

    <table>
    <row>
       <name></name>
       <question_1>answer<question_1>
       <question_2>answer<question_2>
    </row>
<!-- or it can be like this. I can control how the xml is generated-->
    <row>
       <name></name>
       <question>answer<question>
       <question>answer<question>
    </row>
    </table>

the number of questions is different for different xml but they are the same for the rows within one xml. I want the data to appear in tabular form like this

name | question_1 | question_2

Upvotes: 2

Views: 4773

Answers (2)

Dominique
Dominique

Reputation: 4332

As you mentionned it in the question, i think the easiest way to do this is a crosstab. Indeed datacubes work with numeric measures but we can workaround it by creating a dummy measure with the field "answer" as expression in the underlying datacube. Set the type of the measure to "String" and the aggregate function to "FIRST" , then the crosstab should display the answer of each question in cells

Upvotes: 2

user3660637
user3660637

Reputation: 624

You could do the following:

  • Add a list to your report
  • In the List Header add a Grid of 1 column and some rows
  • In each row of this Grid add the title of the row
  • In this Grid, set the width to the size of the text
  • In the List Detail add another grid of 1 column and as many rows as you need
  • In this second Grid, drag the data sets that you want into each cell
  • Set this second Grid's General > Display property to inline (instead of block)
  • In this second Grid, set the width to the size of the text

Upvotes: 0

Related Questions