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)
BIRT: creating custom dataSetRow / using dataSetRow in js
wasman
Hi all. Scenario I have some report with groups Mark && Customer (String) price - is decimal, id is int<br />
<br />
| Mark | [price] | {expresion} | //in price in group of Mark<br />
<br />
| Customer | [id] | |<br />
<br />
price has aggregateOn Mark and aggregateFunction SUM<br />
<br />
in {expresion} I need to show rounded value of [price] with next rule(script on render) :<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if(
Total.sum(BirtMath.round(dataSetRow["PRICE"])) != BirtMath.round(Total.sum(dataSetRow["PRICE"])) )
{
this.getStyle().color ='$COLOR$'
}</pre>
<br />
dataSetRow["PRICE"] have all price`s. but I need only those who is in group Mark somtink like grouped(dataSetRow["PRICE"],"Mark")<br />
<br />
Questions : 1: How to do this in javascript function? 2: If it is not possible , how to do this by another way?<br />
Thank you.
Find more posts tagged with
Comments
mwilliams
Hi wasman,
So, you want to know how to group on Price and Mark together at the same time? Maybe I'm still a little confused. Can you show some sample data what it would look like in your dataSet and what you'd like the report to look like?
wasman
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="70948" data-time="1291297130" data-date="02 December 2010 - 06:38 AM"><p>
Hi wasman,<br />
<br />
So, you want to know how to group on Price and Mark together at the same time? Maybe I'm still a little confused. Can you show some sample data what it would look like in your dataSet and what you'd like the report to look like?<br /></p></blockquote>
<br />
Thank you for reply. <br />
<br />
Sorry, I was confused about the way we could describe own dataSetRow, and mining of dataSet at all.<br />
So, now as I understand we can say that it is some kind of Collection (array of element), and we can use it as:<br />
<br />
if we have in our datasorce numbers of "PRICE" elements , so the row["PRICE"] is representation one of them and birt iterate over them , and dataSetRow["PRICE"] is representation of collection (array) of all row["PRICE"].<br />
So if we need to calculate some "PRICES" in group (aggregation)("PRODUCT" for example) and at the same time we want to have access to each element of this dataSetRow we should create computed column with aggregationOn "PRODUCT", lets name this computed column ac "CC_PRICE_PRODUCT".<br />
So in my case I need to calculate is roun of sum of "CC_PRICE_PRODUCT" element is equal to sum of rounded each element of "CC_PRICE_PRODUCT". Here is it :<br />
<br />
Total.sum(BirtMath.round(dataSetRow["CC_PRICE_ISSUER"])) != BirtMath.round(Total.sum(dataSetRow["CC_PRICE_ISSUER"])) )<br />
I am expecting that BirtMath.round(dataSetRow["CC_PRICE_ISSUER"]) will give me collection (array) of rounded elements from dataSetRow["CC_PRICE_PRODUCT"]).<br />
<br />
<br />
<br />
sample data (lets say the Price is some costume prices for PRODUCT ):<br />
in dataSetRow PRICE : for car 45.3, 54.90 , for bus 68.4 60.4<br />
<br />
PRODUCT Price rounded prices<br />
<br />
car 100.2 100 // round of sum is 100 and sum of round is 100<br />
bus 128.8 <span style='color: #FF0000'>129</span> // round of sum is 129 and sum of rounds is 130 , mark it red<br />
<br />
Will this trick work correctly for me ?<br />
<br />
Thank you!
mwilliams
If I'm understanding correctly, you should be able to group your table by "vehicle type" (bus, car) and create the aggregations that do the sums how you'd like. Then, in your element script that you want to highlight, you'd just compare the aggregations with something like:
if (row["Agg1"] != row["Agg2"]){
//change text to red
}
Let me know if I'm still not understanding.
Hiremath
hi ,
how to get the grant total value for the three diffrent data sets please suggest.
Thanks,
vishwa
mwilliams
If you have 3 dataSets with many rows, you can create a computed column in the dataSet that is the SUM of the rows. You can grab this value in the script of your dataSet for all 3 dataSets and store the values in variables. If it's just a single row in each dataSet, you can simply grab the row value and store it in a variable. You can then recall these variables in a dynamic text or data element within your report. Hope this helps.