I have 3 tables:
1) a date table which has unique promotion start and end dates.
2) Rep table which has 1 record per rep with a file creation date.
3) History table which has one row of sales results by rep by report date going back to 2005
I would like to take the date table in file #2 and compare it to the rows in the date table. If the file creation date is between the program start and end dates, I want to summarize the sales between those dates from the history table.
For example:[U]
date table has the following first two rows of data
Row1: Program start_date of 6/24/15 and Program End date of 12/23/15; Accumulation start 12/24/2014 Accumulation End 12/22/1015
Row 2: Program Start of 12/23/2015 and program end date of 6/22/2016; accumulation start 6/24/2015 Accumulation end 6/21/2016
Rep Table: Creation Date 12/22/2015
If the Table Creation date is between 6/24/15 and 12/23/15, I would like to summarize the sales by Rep for the dates of 12/24/2014 - 12/22/2015.
Next Example: We are now in April and the file creation date is 4/12/15. I want to summarize the sales for the reps for the date of 6/24/2015 - 6/21/16.
How do I write iif statements to accomplish this?
1) a date table which has unique promotion start and end dates.
2) Rep table which has 1 record per rep with a file creation date.
3) History table which has one row of sales results by rep by report date going back to 2005
I would like to take the date table in file #2 and compare it to the rows in the date table. If the file creation date is between the program start and end dates, I want to summarize the sales between those dates from the history table.
For example:[U]
date table has the following first two rows of data
Row1: Program start_date of 6/24/15 and Program End date of 12/23/15; Accumulation start 12/24/2014 Accumulation End 12/22/1015
Row 2: Program Start of 12/23/2015 and program end date of 6/22/2016; accumulation start 6/24/2015 Accumulation end 6/21/2016
Rep Table: Creation Date 12/22/2015
If the Table Creation date is between 6/24/15 and 12/23/15, I would like to summarize the sales by Rep for the dates of 12/24/2014 - 12/22/2015.
Next Example: We are now in April and the file creation date is 4/12/15. I want to summarize the sales for the reps for the date of 6/24/2015 - 6/21/16.
How do I write iif statements to accomplish this?