lulu79 0 Junior Poster in Training

Hi, I have 2 datagridview.
1 to show TANTOU, TOTAL SUM of DURATION and COUNT of event happened.
Another 1 is to show TANTOU, AVERAGE of DURATION and COUNT of event happened.

I have use LINQ function to get the result.
But how can i combine it so that i can show both result in the same datagrid?
(means, I just use 1 LINQ function that can display TANTOU, SUM, AVERAGE, and COUNT)

here is the code of sum:

Dim group As IEnumerable(Of DataRow) = _
                From row In Ds.Tables(0).AsEnumerable() _
                    Group row By TANTOU = row.Field(Of String)("TANTOU") Into grp = Group _
                    Order By (TANTOU >= Convert.ToString(TANTOU)) _
            Select DTRow(grpDT, _
                                 New Object() {TANTOU, _
                                               New TimeSpan( _
                                                grp.Sum(Function(r2 As DataRow) TimeSpan.Parse(r2.Field(Of String)("EVENTTM")).Ticks _
                                                            ) _
                                                          ), _
            grp.Count() _
                                                         } _
                                                        )

And here is the code of average:

           Dim group As IEnumerable(Of DataRow) = _
                From row In Ds.Tables(0).AsEnumerable() _
                    Group row By TANTOU = row.Field(Of String)("TANTOU") Into grp = Group _
                    Order By (TANTOU >= Convert.ToString(TANTOU)) _
            Select DTRow(grpDT, _
               New Object() {TANTOU, _
                             New TimeSpan(CType( _
                                grp.Average(Function(r2 As DataRow) TimeSpan.Parse(r2.Field(Of String)("EVENTTM")).Ticks),  _
                                Int64 _
                                ) _
                                ), _
                                grp.Count() _
                                } _
                                )
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.