Lee Ingalls
asked on
Crystal XI selection criteria for last record based upon date.
This record selection formula has me stumped. I want to report on active customers that have had no quote activity in the last 6 months from the current month.
CustCode.Active = Y is the easy part
Quote numbers are sequentially assigned regardless of customer... ideally I would like to list the last 3 quotes for each customer.
Two Tables: CustCode and Quote
Join Fields: CustCode.CustCode = Quote.CustCode and CusCodec.SalesId = Quote.SalesId
Exclude all customer quotes that have Quote.DateEnt or Quote.DateMod within 6 months of the current month.
If the last Quote.QuoteNo is 6 months or older from current month based on Quote.DateEnt or Quote.DateMod
Include the last 3 records consisting of: CustCode.Active, CustCode.SalesID, CustCode.CustName, Quote.QuoteNo, Quote.DateEnt, Quote.DateMod
CustCode.Active = Y is the easy part
Quote numbers are sequentially assigned regardless of customer... ideally I would like to list the last 3 quotes for each customer.
Two Tables: CustCode and Quote
Join Fields: CustCode.CustCode = Quote.CustCode and CusCodec.SalesId = Quote.SalesId
Exclude all customer quotes that have Quote.DateEnt or Quote.DateMod within 6 months of the current month.
If the last Quote.QuoteNo is 6 months or older from current month based on Quote.DateEnt or Quote.DateMod
Include the last 3 records consisting of: CustCode.Active, CustCode.SalesID, CustCode.CustName, Quote.QuoteNo, Quote.DateEnt, Quote.DateMod
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The database is SQL Server 2008.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Using a view and directly from the report were both successful. I re-purposed mlmcc's command and used james0628's suggestion of narrowing the scope of records and NOT needing both the CustCode and the SalesID... CustCode was sufficient. You guys rock!!
DateDiff(M,Quote.DateEnt,C
as for printing out the three records you will probably have to do a formula loop.
Formula reset in the group header
formula to count to three in the details, then have a suppression on the details that checks if the formula is equal to three.