Skip to main content



      Home
Home » Archived » BIRT » Obtaining value from previous row in cube(Obtaining value from previous row in cube)
Obtaining value from previous row in cube [message #1248769] Mon, 17 February 2014 11:41 Go to next message
Eclipse UserFriend
I just started using BIRT last week and need some guidance. I would like to create a bar chart of monthly profits for a currency trading account from a table that contains hourly entries of the floating equity and realized profits to date.

I tried aggregating by month and subtracting the first row from the last row, but this is not accurate enough because there is an hour that is not included in the chart. To get an accurate chart I need to be able to subtract the last value for the month from the last value of the previous month.

Is it possible to access the previous row of aggregated data directly, or do I need to use java script to save the value of the previous row in a variable (this assumes rows are processed sequentially). If the value is stored in variable, is it possible to scope the variable to the chart?

Re: Obtaining value from previous row in cube [message #1249567 is a reply to message #1248769] Tue, 18 February 2014 06:33 Go to previous message
Eclipse UserFriend
This might drive you to a complex report, hard to develop and to maintain. You would probably better solve this issue within the relevant dataset, rather than during the render of the chart. Something like this (obviously the dataset should be sorted by month & hour in month):

In "initialize" event of the report, we can declare a global variable such:

lastHourMonthValue=0;   //don't set "var" to declare a global variable


In the dataset, create a computed column to represent the corrected value. In the expression, something like:

if (<myConditionToDetectLastHourOfMonth>){
   var previousValue = lastHourMonthValue; //this time we declare a local variable
   lastHourMonthValue=row["myColumnHourValue"];//we update our global variable
   (row["myColumnHourValue"]-previousValue); //value actually returned to the computed column
}else{
  row["myColumnHourValue"]; //not a last hour in month, so we just return the original column value
}


And last but not least, we can now use this computed column in the datacube instead of the original column.

I hope this helps.

[Updated on: Tue, 18 February 2014 06:34] by Moderator

Previous Topic:Need Help on showing custom error message in BIRT report
Next Topic:[solved] Don't collapse grid's empty cells
Goto Forum:
  


Current Time: Sun Aug 31 18:55:52 EDT 2025

Powered by FUDForum. Page generated in 0.03516 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top