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)
Filter expression - how to use data set column
dyeager
Good morning,
I've got a data set that looks like this:
Item / Amount
item1 / 100
item2 / 50
item1 / 120
item1 / 30
item2 / 20
I want to add a computed column that to my data set that simply gives me the sum of all of each item, so the result would be:
Item / Amount / ItemTotal
item1 / 100 / 250
item2 / 50 / 70
item1 / 120 / 250
item1 / 30 / 250
item2 / 20 / 70
I thought this would be reasonably simple using an aggregation plus a filter expression, but there doesn't seem to be a way to dynamically assign the filter - for example I know if I simply set the filter to row["Item"] == "item1" I will get my total for item1, but I don't know how to dynamically do this. Trying to store the value of the current row in a filter expression doesn't seem to work - I've tried something like:
var currentval = row["Item"];
row["Item"] == currentval;
The problem is it gives me the overall total because that is always true - any idea on how to do what I want here? Thanks a ton!
Find more posts tagged with
Comments
mwilliams
Hi dyeager,
Are you not wanting to group these values in a table and just supply the sum? You want them to stay in their order and have the sum for the group next to them? Is this the case? Let me know.
dyeager
I would like them to stay in their order and have the sum for their group next to them. Thanks very much for responding!
mwilliams
What is your BIRT version? I'll make up a simple example that shows one way to do something like this.
dyeager
Using 2.5.2! Thanks again.
mwilliams
dyeager,
Take a look at this report. It has a hidden text box bound to the dataSet so that the calculations can be done prior to creating the table. In the onFetch method of the dataSet, I created variables for each customer and kept their totals in this variable. I then recalled these variables by customer name in the dynamic text box in the table. Hope this helps. Let me know.
dyeager
Thanks a ton, taking a look at it this morning!
dyeager
This worked beautifully - the key trick I was missing here was the hidden text box bound to the dataset BEFORE my table so that the calculations were done early enough. Cleverly done! Thanks a ton.
mwilliams
Not a problem. Let us know whenever you have questions!