Thanks. Revisiting the joins helped improve the results but I'm still missing something. After my post, I tested the formula a different way and confirmed that it is correct. There are additional formulas in the selection criteria and the report looked okay until I added the date formula, so I assumed it was the issue but now I know the problem lies elsewhere. Let me explain more fully my requirement to see if you can provide some further insights.
I want to display a record in every instance one of two conditions is met:
1) A new order was entered in the past seven days, {table1.orderdate}, for a particular product, {products.code} = "IUD", or
2) An order change for a particular product, {products.code} = "IUD", has occurred after the order process date, {table1.processdate}, and during the past seven days
Order change records are written to log tables, which contain a transaction date stamps (date & time). There are several of these log tables, one of which is table2. As an example, I am using the transaction date stamp of table2, {table2.changedate}, to limit the report to changes occurring in the past seven days but after the original process date and time, { table1.processdate}.
I need to display the record each time either criterion is met. For example, if a new order was created three days ago but it was changed the next day, the record would appear on the report twice, once in connection with the new order and the second time to show the subsequent update to the order.
Based on these requirements, I’ve written the selection formula below using different variations but none of them work properly. Writing it one way, too many change records from table2 are displayed; changing it other ways displays only the new orders or just those records that have updates. Could you review the syntax below and tell me where I may be going wrong with my logic and how to capture all of the desired records?
currentdate < dateadd('d',7,{table1.orderdate}) and
{products.code} = " IUD" or
currentdate < dateadd('d',7,{ table2.changedate }) and
{table2.changedate} >={ table1.processdate} and
{products.code} = "IUD"