Groupby with count

Two Stars

Groupby with count

task.JPG

Please help me out this in talend.


Accepted Solutions
Sixteen Stars

Re: Groupby with count

OK, this is a little difficult to talk you through on here, so I have knocked up a quick example Job in v6.2.1. If you are using a later version of Talend you will be able to import this.

 

The important logic is in the tMap and the tAggregate. 

 

1) I combine the Name fields

2) I add a 1 to non-numeric rows and a 0 to numeric rows then use the tAggregate to "sum" that field ....giving the count.

3) I group by the Name field and return only the first record of the Group

 

 

 

 

 

 


All Replies
Sixteen Stars

Re: Groupby with count

You need to give more information. We will need precise rules for grouping which are not provided. For example, are only non-numeric IDs that come after numeric IDs counted? What happens is Nam1, Name2 and Name3 all have values? What happens if the same ID (numeric) has different Names?

 

You need to analyse this and fully understand your problem so that you can ask for advice on how to achieve it.

Two Stars

Re: Groupby with count

Hi Hall,

Thanks for your reply.

 

1. Are only non-numeric IDs that come after numeric IDs counted?

---Yes, non-numeric IDs that come after numeric IDs should be counted.

 

2.What happens is Nam1, Name2 and Name3 all have values?

---Either of Name1, Name2 and Name3  have value

 

3.What happens if the same ID (numeric) has different Names?

---Same ID with same names is considered.

 

Tried using Tmap & aggregate row, but things not worked for me

Please help me out Hall.Much appreciable

 

Regards,

Blessey

Sixteen Stars

Re: Groupby with count

OK, this is a little difficult to talk you through on here, so I have knocked up a quick example Job in v6.2.1. If you are using a later version of Talend you will be able to import this.

 

The important logic is in the tMap and the tAggregate. 

 

1) I combine the Name fields

2) I add a 1 to non-numeric rows and a 0 to numeric rows then use the tAggregate to "sum" that field ....giving the count.

3) I group by the Name field and return only the first record of the Group

 

 

 

 

 

 

Two Stars

Re: Groupby with count

Great..!

Thanks for all your help & your time Hall.Worked for me

 

Regards,

Blessing