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)
removing duplicates without using suppress duplicates
kedd
Hello everyone, I have use the suppress duplicates and it works fine for string but in my case I have also duplicates in numbers (counts) which I have to remove, I just have to retain the original.
I have result like this:
group |owner| count
data1 | abc | 3
data1 | def | 3
data1 | ghi | 3
data2 | eee | 1
data3 | fff | 1
data4 | ggg | 2
data4 | hhh | 2
I have achieved this using suppress duplicates in column 'group':
group |owner|count
data1 | abc | 3
_____ | def | 3
_____ | ghi | 3
data2 | eee | 1
data3 | fff | 1
data4 | ggg | 2
_____ | hhh | 2
but when I use suppress duplicates in 'count' column it shows like this:
group |owner|count
data1 | abc | 3
_____ | def |___
_____ | ghi |___
data2 | eee | 1
data3 | fff |___
data4 | ggg | 2
_____ | hhh |___
the count for data3 is gone too using suppress duplicates in 'count' column because count from data2 and data3 are both '1'
What do I do now? how do I remove the duplicates that will not affect the next row?
Thanks in advance and more powers!
Find more posts tagged with
Comments
kclark
I've attached an example of one way you could do this. What I did was I added <br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var array = new java.util.ArrayList();
array.add("Start of array");
reportContext.setPersistentGlobalVariable("array", array);</pre>
<br />
To the initialize() of my report.<br />
<br />
Then I wrote some script that checks if the current value is in the array. If it isn't then it adds the current value leaving it. Each time the report creates a new item it checks that value against the array to see if it's already been displayed. If it has then it is removed.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var array = reportContext.getPersistentGlobalVariable("array");
var arrayLen = array.size();
if(arrayLen == 1) {
// Add current value to array because it's not a duplicate
array.add(this.getValue());
// Make it a PGV
reportContext.setPersistentGlobalVariable("array", array);
}else{
var addToArray = true;
for(i=0;i<arrayLen;i++) {
if(this.getValue() == array.get(i)) {
this.setDisplayValue("");
addToArray = false;
}
}
if(addToArray == true) {
array.add(this.getValue());
}
reportContext.setPersistentGlobalVariable("array", array);
}</pre>
<br />
The above code goes in the onRender()
kedd
Hi kclark,
Thank you for your response... I forgot to tell that I am using BIRT 2.3.2, I cannot open the file you've attached, it says it was made from higher version... I don't know much about this BIRT Report designer that's why I am not aware of what you we're saying about the initialized() and onRender() . . .