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)
Group by id, sort by name, remove name duplicates when same person
Elja
<p>Hello.</p>
<p>I've bumped into a seemingly difficult problem.</p>
<p> </p>
<p>The report I'm creating groups customers by "customer_id". In Edit Group Details I've defined in the Sorting -tab the sorting to be done by "customer_name".</p>
<p> </p>
<p>I'd also like to suppress duplicates, which is easily done from Colum properties - Advanced - Suppress duplicates.</p>
<p> </p>
<p>Now, as long as customers have different names, everything is fine.</p>
<p> </p>
<p>The problem arises when a following situation appears:</p>
<p>Customer_id: 1, customer_name: Smith John</p>
<p>Customer_id: 9, customer_name: Smith John</p>
<p>Customer # 9 being a different person than customer # 1.</p>
<p>OBS: Customer_id IS NOT shown in the report (I've hidden the column).</p>
<p> </p>
<p>When grouping is done by customer_id, Birt gathers customer #1 rows in a group and customer #9 in another, which is as it's supposed to work.</p>
<p>MORE problems seem to arise as I have to group also by 2 other fields: service_id and serviceincredient_id..</p>
<p> </p>
<p>BUT: If I sort by customer name AND suppress duplicates, It seems that only the first name appears. Without suppressing the duplicates the name appears in every row and makes the report more difficult to follow.</p>
<p> </p>
<p>What I'd like is that grouping is done by customer_id and sortin by customer_name. The first appearance of customer name would be shown on the report (duplicates suppressed) AND when the customer_id changes, the customer_name would be shown again, even if it was exactly the same as the former customer_name.</p>
<p> </p>
<p>Something like this:</p>
<p>Customers: id #1 at first and id#9 as the name appears again:</p>
<p>Customer, Service</p>
<p>Smith John Cleaning</p>
<p> Meals</p>
<p> Vacuuming</p>
<p>Smith John Cleaning</p>
<p> Massage</p>
<p>In the background, customer_id would do the grouping..</p>
<p> </p>
<p>Any ideas how this could be achieved?</p>
<p> </p>
<p>Thanks a lot, Elja</p>
Find more posts tagged with
Comments
micajblock
<p>Yes, do not use suppress duplicates and do this in script. If you provide a sample flat file and version of BIRT you are using I can build an example.</p>
Elja
<p>Hello mblock.</p>
<p> </p>
<p>Is there a simple place to check the Birt version? My Eclipse version is 4.4.0 and based on the time I installed Birt (late fall last year), it is also 4.4.0.</p>
<p> </p>
<p>What kind of requirements is there for a flat file you asked for? I'll attach the .rptdesign to this conversation as it is and I'll make the required changes if you could give some instructions what should be done..</p>
<p> </p>
<p>- Elja</p>
<p> </p>
<p>In the report I've used both id-fields for grouping as name fields for viewing with (asiakas = customer, palvelu = service, palvelusisalto = service content). Customer, service and service content might contain values by the same name but with a different id..</p>
<p> </p>
<p>.. and THANKS a lot for your help.</p>
micajblock
<p>A CSV file would be great.</p>
Elja
<p>Hello again.</p>
<p>Ok, we were talking about the data itself.. I fetched a set from the database and converted it into a .csv file. at the top of the file are the names of the fields shown from row 3 to the end.</p>
<p> </p>
<p>- Elja</p>
micajblock
<p>Sorry I was not able to use your CSV file so I created data using a scripted data set. The data is on purpose not in order. What I did was the following:</p>
<p>Grouped by Customer ID and sorted the group on the Customer Name.</p>
<p>Added the below script to the onCreate event of the group:</p>
<pre class="_prettyXprint">
groupCounter=0;</pre>
<p>Added the below script to the onCreate event of the Customer Name data item:</p>
<div>
<pre class="_prettyXprint">
groupCounter++;
if (groupCounter > 1) {
this.getStyle().display="none";
}</pre>
</div>
Elja
<p>Thanks a lot mblock, I'll look into it!</p>
<p> </p>
<p>- Elja</p>
Elja
<p>Hello again, mblock.</p>
<p> </p>
<p>Your solution seems to work really fine on Birt side. Thanks again!</p>
<p> </p>
<p>There are some complications in the production interface, but they are probably related to some other issue..</p>
<p> </p>
<p>- Elja</p>
micajblock
<p>You're welcome.</p>
Elja
<p>Hei mblock, still a simplish question:</p>
<p> </p>
<p>is groupCounter just a variable? If I wanted to restrict other duplicate values in the same report in similar way, can I just use a name like groupCounter2?</p>
<p> </p>
<p>- Elja</p>
<p> </p>
<p>Script:</p>
<p><span>groupCounter</span><span>++;</span><br><span>if</span><span> </span><span>(</span><span>groupCounter </span><span>></span><span> </span><span>1</span><span>)</span><span> </span><span>{</span><br><span>this</span><span>.</span><span>getStyle</span><span>().</span><span>display</span><span>=</span><span>"none"</span><span>;</span><br><span>}</span></p>
micajblock
<p>Yes. Each group would need its own variable.</p>
Elja
<p>Thanks a lot!</p>
<p> </p>
<p>- Elja</p>