Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Sequence of Aggregation and Script eval
ravencsi
<p>I have a data element called duescost in a bound table that returns a value based on the value of a global variable (defined as a variable with report scope in the data explorer):</p>
<p> </p>
<div>if(vars["chapterrow"]== 0){</div>
<div>row["cost"];</div>
<div>}else{</div>
<div> if(vars["chapterrow"]== 1){</div>
<div> 0;</div>
<div> }else {</div>
<div> if(vars["statelevel"] == 1){</div>
<div> 30;</div>
<div> }else if (vars["statelevel"] == 4){</div>
<div> 20;</div>
<div> }else if(vars["statelevel"] == 2){</div>
<div> 10;</div>
<div> }else{</div>
<div> 0;</div>
<div> }</div>
<div> }</div>
<div> }</div>
<div> </div>
<div>This renders the proper value in the row, but when an aggregate is done on this data element in the table footer, it always sums the value of the data element that with the vars[chapterrow"] variable at 0, the default. There is another data element in the row that updates the global vars:</div>
<div> </div>
<div>
<div>if(row["chapter_id"] != null){</div>
<div>vars["chapterrow"] = vars["chapterrow"] + 1;</div>
<div>}</div>
<div>if(vars["chapterrow"] == 0){</div>
<div>statelevel = row["category_id"];</div>
<div>}</div>
</div>
<p> </p>
<p>If I display the value of vars["chapterrow"] in the table it is always accurate. It is as if the gobal var is only being called during the onRender event of an object.</p>
<p> </p>
<p>For example, in one record I will have two dataset values, 75 and 30. With the script, the 30 value should be altered to 0. So i will have the duescost displaying in two rows correctly, e.g. $75 and $0, but the aggregate is $105, which is the sum of a correct $75 plus the unaltered value of $30 for the second item</p>
<p> </p>
<p>How can I force the duescost to be totaled AFTER the variable is updated and retrieved?</p>
<p> </p>
<p> </p>
Find more posts tagged with
Comments
ravencsi
<p>Used PGV's instead and it works. Important to put script for advancing counter var in the onCreate event of a detail row positioned above the detail row where the var needs to be evaluated. Putting the script in a data element or text object (in the objects' onCreate) placed in the upper row itself does not evaluate it in time.</p>