Reputation: 8601
I have a C# 2010 application that uses Crystal Reports for VS 2010. My report's purpose is to show where a person should be each day of one or more weeks. The format is this:
Please note that it is displayed in pairs, rather than a table with a general header.
It uses a DataSet that contains two DataTables, one for the header dates and one for the location.
The problem is that if I have n items in each DataTable, the report displays n^2 pairs of header / location instead of just n. The pattern is similar to a Cartesian product of the two tables.
I think it might have something to do with the linking part in the report's Database Expert but I couldn't manage to fix it. It contains no links right now.
The DataSet I use looks like this:
Upvotes: 0
Views: 1486
Reputation: 6148
You need to link the tables to only get n
rows.
Ideally:
ID
column to the Headers
table. Make it the one primary key, and an auto-incrementing identity.HeaderID
column to the WeekTable
table, and make it a foreign key to the Headers
table on the ID
column.The Headers
table should now only include one row for each week, so if you have four employees they will all have the same HeaderID
for a given week.
Upvotes: 1
Reputation: 26262
Why do you need a table for the headers? What are you trying to accomplish?
Why not add a date (StartOfWeek) to the WeekTable that represents the starting date of the week? If you have that date, each column header would be a formula field that calculates the day based on the StartOfWeek field. So much easier and it eliminates the Cartesian product that you are experiencing.
** edit **
There would be 7 header formulae (one for each day):
//{@Sunday}
DateAdd("d", 0, {WeekTable.StartOfWeek})
...
//{@Saturday}
DateAdd("d", 7, {WeekTable.StartOfWeek})
Add each field to the Page Header section and format as desired (they are Date values).
Upvotes: 1
Reputation: 6027
You may need to explain a little further what your "header dates" are. But from what you're saying they are not linked to the main data, in which case i would probably use a subreport in the header.
Upvotes: 0