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

  • External Monitor Issues - MacBook Pro +Acer

    Hello Everyone!! I currently have my new Macbook Pro hooked up to a Thunderbolt display and all is running well!  BUT, I also have a mid 2009 MBP that I am setting up with a new ACER S271HL monitor (one of their newer models) and I am having some "qu

  • Intermittent color saturation problem

    My display has very saturated colors and too much contrast - on both the laptop display and on an external monitor. It goes back to normal if I unplug and reconnect the external display, or in an unpredictable way just on the macbook. Everytime I res

  • Some of my notes disappeared. How can I retrieve them?

    Some of my notes disappeared without even erasing them. How can I retrieve them?

  • ThinkVantage Toolbox does not run after BIOS update

    Lenovo ThinkVantage System Update Tool on my T410 ThinkPad (2518EWG) offered me download and installation of ThinkPad BIOS Update Utility US version 1.28-1.11. Since then,  whenever I try to run Lenovo ThinkVantage Toolbox I receive a message: „This

  • Archiving weirdness

    I archived my Documents folder today and copied it over to my other Powerbook, which runs OS 9. The documents folder on my Powerbook that runs OSX (10.4.6) is 8.76 GB (according to Get Info). Two weird things happened as I did this. 1) As OSX was fin