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)
Saving row column value to global variable
mbsolar
I am trying to save the value of a rows column to a global variable that I can used in the following row for a condition. I could use help in retieving the previous row in a table's (or dataset) column value to be used in a condition in the following row (or dataset) of that table.
I have declared the global variable in the initialize script of the report (I had tried to set this up in the Create script of the table. I had the same result.)
I set up the condition to compare the global varible to the current row's column value in the Create script of the table's row followed by the state ment to set the global varible to be equal to the row column value in the Create script of the table's row.
Condition always seem to be true a row too late. I am obviously setting the global varible too late or executing the coondition too soon.
Other variations I have tried result in worse results. I am still unsure of the javascript syntax, as well as BIRT's different areas for placing script.
The version of BIRT I am using is 2.2.2
Thanks,
Mike
Find more posts tagged with
Comments
mwilliams
Hi Mike,
Can you attach a report design with the script you're trying to use on the table rows so I can see more what you're trying to do? The only scripts I see in the currently attached report are for checking your output format. Thanks.
mwilliams
Nevermind my last post. I was looking at the different report I have with a somewhat similar name. I'll look at your report design and let you know what I see.
mwilliams
Mike,<br />
<br />
Is your data sorted by "System ID" when you bring it in? If it is, you can probably get the way you're doing it to work by changing your JS slightly to:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if ( row["SystemIdentifier"] == globalvarSystID ){
globalvarDay++;
}
else{
globalvarDay = 1;
globalvarSystID = row["SystemIdentifier"];
}
</pre>
<br />
Another way you could do this is with the data sorted in the dataSet, you can create computed columns for globalvarSysID and globalvarDay in the edit dataSet box.<br />
<br />
Let me know if you have any questions. I can probably make a simple example doing something similar with the sample database if you don't get it to work. Good luck.
mwilliams
Mike,<br />
<br />
Ok, this works in a computed column or by simply placing a data element from palette into your report under the "Day of Month" header and using this as the expression with type integer. I've also attached a screenshot of my results.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if ( row["SystemIdentifier"] == globalvarSystID ){
globalvarDay++;
globalvarDay;
}
else{
globalvarDay = 1;
globalvarSystID = row["SystemIdentifier"] ;
globalvarDay;
}
</pre>
<br />
Let me know if you have any questions.
mwilliams
I didn't sort the data, so some "system ID's" repeat, but it works none the less.