Link to home
Start Free TrialLog in
Avatar of andre72
andre72

asked on

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
Avatar of iamozymandias
iamozymandias

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....
Avatar of Mike McCracken
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
Avatar of andre72

ASKER

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 ...
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
Avatar of andre72

ASKER

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 ...
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andre72

ASKER

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?
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
Avatar of andre72

ASKER

Thanks I will open a new thread for my sum problem ...