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)
Retrieve Top AND Bottom N Data from a DataSet
apeterso
Hi,
I need to create a bar chart using the Top 10 and Bottom 10 data in a certain column of a dataset.
I've tried the following filtering approaches with no success:
1. Create two separate datasets with the a single filter, top 10 and bottom 10 for each. Then create a joint data set using these two datasets. This failed miserably because the columns were duplicated.
2. Since what I really need is a Top N filter OR Bottom N filter on the said dataset, I tried this javascript after digging around the forums for the syntax:
Total.isTopN(row["Price"],10) || Total.isBottomN(row["Price"],10)
This returned the complete dataset with no filtering at all. I wonder if the function is outdated? I'm using BIRT 2.5.2
Any ideas?
Thanks.
Find more posts tagged with
Comments
mwilliams
Hi apeterso,
Your first idea in your post above should work. You would just have to create computed columns to join the like columns into 1.
For your second idea, yes, I believe the total functionality has gone away with the progression of aggregations.
I'll try a couple things and get back to you with a sample if I get something working.
mwilliams
For another option, you could make sure you order your data in your dataSet query by the field you want to have the top and bottom 10 of. Then, create two computed columns, one that does a running count to keep track of the line number and one that does a count to know the total number of lines. Then, you can do a dataSet filter that filters your dataSet with an expression like the following:
row["lineNumber"] Not Between 10 and (row["totalLines"] - 10)
Let me know if you have questions.