I am trying to link two different tables by date. table 1: Date is a date and time field table 2: Date is a date field
I am using Crystal report 11 and in the report options; converting to the date field is not an option
Can't do such a join in Crystal.
Consider creating a View in the DBMS to take care of converting the data type in one of these tables.
Other options:
No join but use a record selection condition. Performance would suffer but if number of records is not too large that should work.
Use a Command.
Use one table in the main report and link to the other via a subreport link.
Related
I have a report I am creating through an ODBC connection. The report includes several invoices, where each invoice has several products. There is also a table which contains all the historical price changes for each product (field: unit-price). Currently there are duplicate product records being pulled, one for each time there was a price change. Therefore, I need to filter my data so that only the most recent unit-price is shown (date field: effective-date). How can I do this via the "Select Expert?"
In short, show the product's unit-price for the most recent effective-date.
Thank you!
You'll need to create a sql-expression field to get the most-recent effective date, then use this field in the record-selection formula.
// {%MAX_EFFECTIVE_DATE}
// most-likely you'll need to alias the table in the main report for this to work
(
SELECT Max(effective_date)
FROM price_history
WHERE product_id = price_history_alias.product_id
)
Record-selection formula:
{price_history_alias.effective_date}={%MAX_EFFECTIVE_DATE}
Instead of doing it in select expert. group by effective date and set the ordering as Descending.
Please suggest me to get this requirement.
I have a report where I need show data wise sites.Suppose if I click on particular date it should show respected sites.
The date field is coming from different query and sites info is coming from diff query.
Now I need to pass this date field as a parameter to 2nd query.But due to some limitation(nested sub reports) I am not using sub report approach.
I am using drill down concept.
So I have taken both queries in one report only and I written a sub query in 2nd query to get 1st queries date .
Now I am displaying the date parameter in 2nd query as a column.
Now I have date columns in both the queries.
Now what is my doubt is whether I need to link both the queries date fields in links tab(As I need to show sites coming from 2nd query by clicking date field coming from 1st query)
Please suggest .
I have a fairly basic report that needs to show events with a total spend of >$200K OR event attendance >60ppl. The attendance portion is no problem, as it's a simple text field in the table. The expense spend is a field that has to be summed before it can be used, coming from a separate table with multiple entries per event. I have no problem doing this in a summary field dropped in the eventID header or even using a subreport and passing a shared variable to the main report. The problem I run into is that I cannot access this summary field in the report record selection to extract the either or records. Any idea how I can do this accurately?
Create a sql-expression field for total spending:
//{%total_spending}
(
SELECT sum(Amount)
FROM Meeting_Expenses
WHERE MeetingId=Meeting.Id
)
Use fields in record-selection formula:
{Meeting.actual_attendance}>60
AND {%total_spending}>200000
A record in a table contains a range of valid dates, say:
*tbl1.start_date* and *tbl1.end_date*. So to ensure I get all records that are valid for a specific date range, the selection logic is: <...> WHERE end_date >= #dtFrom AND start_date < #dtTo (the #dtTo parameter used in the SQL statement is actually the calculated next day of the *#prmDt_To* parameter used in the report).
Now in a report I need to count the number of records for each day within the specified data range and include the days, if any, for which there were no valid records. Thus a retrieved record may be counted in several different days. I can do it relatively easily with a recursive CTE within the data set, but my rule of thumb is to avoid the unnecessary load on the SQL database and instead return just the necessary raw data and let the Report engine handle groupings. So is there a means to do this within SSRS?
Thank you,
Sergey
You might be able to do something in SSRS with custom code, but I recommend against it. The place to do this is in the dataset. SSRS is not designed to fill in groups that don't exist in the dataset. That sounds like what you are trying to do: SSRS would need to create the groups for each date whether or not that date is in the dataset.
If you don't have a number or date table in your database, I would just create a recursive CTE with a record for every date in the range that you are interested as you mention. Then outer join this to your table and use COUNT(tbl1.start_date) to find the appropriate days. This shouldn't be too painful a query for SQL server.
If you really need to avoid the CTE, then I would create a date or number table to use to generate the dates in your range.
I'm using Crystal Reports 10.
In my database I have production values for each Date. There's a date column and a qty column. When I run a report on this the dates on the report correspond to the dates in the database, but I'd like the report to display every date and if there is no value for it a 0. Is this possible to do right in the report?
The date is a group field with detail suppressed. The numeric values are a sum of the details placed in the group header, if that makes a difference.
You have 2 questions.
To display a 0 for null values, you can go into your options menu and "convert database NULL values to default"
Alternatively, you can use make a new formula with this code and use if isnull({Table1.Amount}) then 0 else {Table1.Amount}. I recommend this option since it won't affect other fields in the report.
To display every date, you should make a 'helper/index' table in your datasource and right-join your actual data to it. Crystal can't display data for, say, 01/07/2010 if there are no records for it.