Forums BIRT Reports Global Variable and Crosstab

This topic contains 7 replies, has 2 voices, and was last updated by  ani_difranco 2 years, 4 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #116

    ani_difranco
    Participant

    I use BIRT 2.6.2 with flat file (csv) and I have two crosstab. How can I put the Grand Totals (Row Area) of the first crosstab into global variables to use they on the second crosstab to make calculations?

    Thanks

    #117

    joe_dallesandro
    Participant

    Are you wanting to sum all of the grand totals and then place that in a PGV or are you wanting to store them in an array to call them back for specific rows?

    #118

    ani_difranco
    Participant

    I want to store them in an array to call them back, but there is a different method to sum all of the grand totals and then place that in a PVG?

    #119

    joe_dallesandro
    Participant

    You can store the values of grand totals in an array like this.

    From the onPrepare() of your report.

    var crosstab1 = new java.util.ArrayList();
    var crosstab2 = new java.util.ArrayList();

    reportContext.setPersistentGlobalVariable(“crosstab1”, crosstab1);
    reportContext.setPersistentGlobalVariable(“crosstab2”, crosstab2);

    reportContext.setPersistentGlobalVariable(“length1”, length1);
    reportContext.setPersistentGlobalVariable(“length2”, length2);
    And then in onCreate() of each crosstab’s grand total you will need to call back the array, add the value, then set it as a PGV again like this

    var crosstab1 = reportContext.getPersistentGlobalVariable(“crosstab1”);
    crosstab1.add(this.getValue());

    reportContext.setPersistentGlobalVariable(“crosstab1”, crosstab1);
    and

    var crosstab2 = reportContext.getPersistentGlobalVariable(“crosstab2”);
    crosstab2.add(this.getValue());
    reportContext.setPersistentGlobalVariable(“crosstab2”, crosstab2);
    Now you can pull back each value from the PGV. You can test this by displaying the value in a label from the onCreate()

    var test = reportContext.getPersistentGlobalVariable(“crosstab1”);
    this.text = test.get(0);

    #120

    ani_difranco
    Participant

    Thanks, it works. But now how can I get the array index of the second grand total in runtime to perform the calculations (ex. %, diff, ecc.)?

    #121

    joe_dallesandro
    Participant

    To get the second grand total it you would do something like this

    var tab1 = reportContext.getPersistentGlobalVariable(“crosstab1”);
    var tab2 = reportContext.getPersistentGlobalVariable(“crosstab2”);
    var summedValue = tab1.get(1) + tab2.get(1); // get(1) is the second value as the array starts at 0, this will sum the second value from both crosstabs

    #122

    ani_difranco
    Participant

    My problem is another: I have the value of the crosstab1 (global total) on a array, then in report designer I have to use this array in the cells of the crosstab2 (global total and crosstab aggrgation cell). How must I use the array index? This array index, naturally, is different for every column of the aggrgation, but in designer I have only one column for the aggrgation cell and grand total.
    I hope I have described my problem well.
    Thanks

    #123

    ani_difranco
    Participant

    Can you create a sample rptdesign showing what you are trying to do and post it?

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.