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)
Iterate over rows in script?
Rhall
Hi everyone,<br />
<br />
I need to perform an aggregation to some data, but I need much finer control than just simply filtering data. For each row in my query, I need to either add to a value or subtract from it based on other information in the same row. This seems to be beyond what is possible with a normal aggregation, but I'm unable to figure out how to do this. Ideally I would have an expression that looks like this pseudo-code:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var value = 0;
for x in dataSet:
if x.row['foo'] == "yes":
value += x.row['number'];
else:
value -= x.row['number'];
</pre>
<br />
Any and all help will be greatly appreciated!
Find more posts tagged with
Comments
mwilliams
Hi Rhall,
Then you're just wanting to display this value as a summation to the column? Or do you want to keep a running total of this in your report?
Rhall
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="68417" data-time="1284497691" data-date="14 September 2010 - 01:54 PM"><p>
Hi Rhall,<br />
<br />
Then you're just wanting to display this value as a summation to the column? Or do you want to keep a running total of this in your report?<br /></p></blockquote>
<br />
I would want to display it as a single value in the footer of a table.
mwilliams
Rhall,
You could create a computed column in your dataSet that does the computation using a variable you initialize in the beforeOpen of your dataSet. Then, you could place an aggregation in the footer of your report calling this computed field with an aggregation function of "LAST". This would give you the last value of this field in your dataSet. Another thing you could do would be to do these computations in the onCreate of the element you're adding/subracting, storing the current value in a variable each time and then recalling this variable value in a dynamic textbox in your footer.
Hope this helps. Let me know if you have questions.
Rhall
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="68454" data-time="1284579474" data-date="15 September 2010 - 12:37 PM"><p>
Rhall,<br />
<br />
You could create a computed column in your dataSet that does the computation using a variable you initialize in the beforeOpen of your dataSet. Then, you could place an aggregation in the footer of your report calling this computed field with an aggregation function of "LAST". This would give you the last value of this field in your dataSet. Another thing you could do would be to do these computations in the onCreate of the element you're adding/subracting, storing the current value in a variable each time and then recalling this variable value in a dynamic textbox in your footer.<br />
<br />
Hope this helps. Let me know if you have questions.<br /></p></blockquote>
<br />
Thanks for the help mwilliams. I ended up using two computed columns, one to sum all the adds and the other for subtracts. Then in the display area i just made value = row["adds"] - row["subtracts"].