Need this formula to look back 2 full years

In the following code, we are looking to show all records, where, the part# had no sales for the 2 month period selected by the user. But we also do not want to show this part if the current onhand balance is o, and also, we do want to show when was the last sale for this part. THe change i need is that the code here will show the last sales for past year only of calender year. I would like it to show 2 years back, meaning 2 full years from current date. I think i need to have an OR statement here and {SUMPRT.IQYER#} = {?Year} but not really sure. this is a crystal reports formula.
{PARTINV.IEQOH#} <> 0.00 and ( if {?Month}=1 then (({SUMPRT.IQA01} =0 and {SUMPRT.IQYER#} = {?Year}) and ({SUMPRT.IQA12} =0 and {SUMPRT.IQYER#} = {?Year}-1)) else if {?Month}=2 then ({SUMPRT.IQA01} =0 and {SUMPRT.IQA02} =0 ) and {SUMPRT.IQYER#} = {?Year} else if {?Month}=3 then etc...

Hi Paul,
This formula is pretty confusing because I can't decipher which fields relate to what.  I think though you may be overthinking the formula.
It looks like you are evaluating each month of the year individually.  Instead of using nested IFs, have each month as a separate statement.  Better yet, use a case statement like:
{PARTINV.IEQOH#} <> 0.00 And
Select {?Month}
     Case 1:     (({SUMPRT.IQA01} =0 and {SUMPRT.IQYER#} = {?Year})
                    and ({SUMPRT.IQA12} =0 and {SUMPRT.IQYER#} = {?Year}-1))
     Case 2:     ({SUMPRT.IQA01} =0 and {SUMPRT.IQA02} =0 )
                    and {SUMPRT.IQYER#} = {?Year}
     Default:     etc...;
Separating the months into a Case or independant IF should get you your results.
Thanks,
Brian

Similar Messages

Maybe you are looking for

  • How to return a single datetime from multiple rows of MAX(value) in DAX

    Hi I have a Results table with ResultTime, Balance, Equity which is updated with a new row every 5 minutes. I've used SUMX to find opening and closing balances and it has worked so far. Res_OpeningBalance:=SUMX(TOPN(1,Results,Results[ResultTime],1),[

  • When i connect to itunes with my ipod touch it wont let me apply music, apps etc. on to it what do i do?

    Whenever i try to sync music, apps, videos etc. on to my ipod touch from my home computer it wont let me apply where it says 'apply' as it is sort of shaded out. This started happeneing when i downloaded IOS5 so i got a replacement and it did not wor

  • How to encapsulate two games in a new flash document

    Hi mates! Now that I have my first two games I want to encapsulate them in a new document! Here is my idea: Create a new document with 4 keyframes in the main timeline. The first one will accommodate the title and two "play" buttons (each allowing to

  • Dynamic select query with dynamic where condition

    Hi all, I want to use the dynamic select query with dynamic where condition. For that I used the below code but I am getting dump when using this code. Please advice, if there is any other way to achieve this requirement. Thanks, Sanket Sethi Code***

  • Error loading item from WAD

    Hello, I have problems with loading template from WAD to Browser. I created the template and then pushed the button Execute in the browser. I can see only message: Error Loading item* Can you help me pleas. Thanks Petr