• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1100
  • Last Modified:

Display DataTable with Group By in report

Hi,

I need to display a DataTable in a report.
So as the DataTable is not grouped or sorted in any case I need a way to display the DataTable using different Group By options (e.g. by Date, by Customer ...).

As I'm doing my first report in this way with VS 2008 and reporting services maybe you can give me a hint how to make the report.
I think I've to use different reports for any case I need like:
1. Report by date
2. Report by customer
...

And how to group the data - can Crystal Report do so or have I need to use something like LinQ?
As the DataTable will bild in memory I can' use something like a group by query ...

Thanks

Andre
0
andre72
Asked:
andre72
  • 4
  • 4
1 Solution
 
iamozymandiasCommented:
Perhaps if you give a detailed description of how you want the data laid out I could help. For example:

I want 1 report with 2 tables, Table A is sorted/grouped like...., Table B is sorted/grouped like....

~or~

I want a subreport that is grouped like..., while the main report is grouped like....
0
 
mlmccCommented:
Are you trying to do this is MS SSRS or Crystal?

Both tools can handle the report.
How you do that depends on which tool you choose.

In Crystal you can use a formula for the grouping and have a parameter that the user enters to choose the field to group on

Like
If {?GroupParameter} = 'Date' then
    CStr({DateField},'yyyy/mm/dd')
Else  if {?GroupParameter} = 'Name' then
    {NameField}
etc

The only restriction with this method is the formula can only return 1 datattype so in general you have to convert everything to strings.

mlmcc
0
 
andre72Author Commented:
I'm not sure about MS SSRS or Crystal.
Is one of both able to do HTML export?

I've only one not grouped and not sorted table:
Customer  Date  Amount

Ok, gouping and sorting will also be no magic with LinQ I think if it's pissible.

The two reports I need are:
Group by cate and for every day a total sum
Group by customer with sum for every customer

With Access it would talke less than 5 minutes I think but with VS I give it my first try ...
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
mlmccCommented:
I know Crystal can export to HTML and PDF.  I believe SSRS can also.

Crystal can group and sort as you want.

Crystal is much like Access in report development.

mlmcc
0
 
andre72Author Commented:
Than I decide to choose Crystal, thanks.
Can you point out the first steps?

The samples I saw are ever based on a connection to a DB but my DataTable is allready in memory ...
0
 
mlmccCommented:
This question has 1 example
http://www.experts-exchange.com/Database/Reporting_/Crystal_Reports/Q_26989757.html

Here is another of passing the dataset to Crystal
http://www.emoreau.com/Entries/Articles/2006/09/Feeding-Crystal-Reports-from-your-application.aspx

I haven't found a VS2008 version but the basic steps for building a report should be the same as VS2005 Crystal
http://www.businessobjects.com/global/pdf/dev_zone/VS2005_Walkthroughs.pdf

mlmcc
0
 
andre72Author Commented:
Thanks this works fine at all.
My only problem is to build the sum of the amount data.
In the section footer the field for the sum is available and when I edit it I can choose many kind of result:
Min
Man
Count
Count2
Modus
...

But not the sum ...
How can I place the sum there?
0
 
mlmccCommented:
Apparently the field is not a number.  If it is numeric data as strings you can use the Val function to convert it in a formula then sum the formula

Val({YourField})

mlmcc
0
 
andre72Author Commented:
Thanks I will open a new thread for my sum problem ...
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now