Before I answer your question I just want to mention that the report is currently grouped on a fild called VEHICLE_VIN. Ok now that thats out of the way.
COL B is a RT called SoldUnitsJunCIW that does a Distinct Count on a field called VEHICLE_VIN and has the following formula incorporated. Basically it adds up how many cars were sold for the month and becomes the benchmark to calculate the percentages;
{DEL_DATE} in Date (2009,06,01) to Date (2009,06,30)
COL C is a formula field called 4_ServicedvehicleJunCIW that contains the following;
WhilePrintingRecords;
NumberVar CountReportJUNCIW := CountReportJUNCIW
COL D is a formula field called 5_Retention%JuneCIW that contains the following;
{@4_ServicedvehicleJunCIW}/{#SoldUnitsJunCIW}*100
There are actually 5 steps in the process COL C being the result of step 4 and COL D being the result of step 5. I will list steps 1-3 below so you can see the flow.
#########################################
Step 1. The first formula field is called 1_RoDateJunCIW and contains the following;
If {vehicle_inventory1.DEL_DATE} in Date (2009, 06, 01) to Date (2009, 06, 30) and
{service_retention1.RO_DATE} in Date (2009, 07, 01) to Date (2010, 06, 30) then {service_retention1.RO_DATE}
Else Date(1900, 01 ,01)
If the data is within the period that I want it lists the dates or for those outside returns 01/01/1900.
Step 2. Is a formula field called 2_RoDateMaxJuneCIW containing the following;
NthLargest(1,{@1_RoDateJunCIW},{vehicle_inventory1.VIN})
I will get multiple results from step 1 and as I only want to count a single instance I use the NthLargest to throw out a single result.
Step 3. Is a formula field called 3_RoCountJunCIW containing the following;
WhilePrintingRecords;
NumberVar CountJUN;
NumberVar CountReportJUN;
If {@2_RoDateMaxJuneCIW} in Date (2009, 07, 01) to Date (2010, 06, 30) and
DateDiff ("d", {vehicle_inventory1.DEL_DATE}, {@2_RoDateMaxJuneCIW}) <= 365 then
(CountJUN := CountJUNCIW + 1;
CountReportJUNCIW := CountReportJUNCIW + 1)
This counts each result from step 3 should it meet the criteria.
So basically I have these five steps for each one month. So as you can see I am a victim of managing a stack of dates if I want to change the reporting periods.
Edited by keithrichards - 15 Jul 2010 at 1:42pm