locked
Bracketing AND/OR in filter RRS feed

  • Question

  • How do I write a query such that:

    If date > today AND (event type = 1 or event type = 2 or event type = 3)

    display my row?

    Today it evaluates as if the brackets are missing, so that event types 1, 2 and 3 appear in the view, ignoring date.

    • Moved by Mike Walsh FIN Thursday, July 28, 2011 2:23 PM not general (From:SharePoint - General Question and Answers and Discussion (pre-SharePoint 2010))
    Thursday, July 28, 2011 2:14 PM

Answers

  • Melissa,

    Thanks so much. I was filtering a view. I tried the code you suggested, but it didn't work. I had to change it to this:

    Start is less than [Today] AND Event Type = 1 OR

    Start is less than [Today] AND Event Type = 2 OR

    Start is less than [Today] AND Event Type = 3


    Carole
    • Proposed as answer by Rashu,Rahul Saturday, July 30, 2011 8:16 AM
    • Marked as answer by Mike Walsh FIN Wednesday, August 3, 2011 4:19 PM
    Friday, July 29, 2011 11:01 PM

All replies

  • Are you just trying to create a new view of a list with the criteria above?  Your question isn't quite clear on that, so I'm not sure if you're just trying to accomplish a filtered list view, or if you're writing a CAML query somewhere. 

    If you are just trying to create a filtered view, you can do this in the properties of the view page.  Go to the view you wish to edit:

    • Click on the view name on the top right to display the drop down
    • Modify this View
    • Scroll down to the filter section
    • Select the radio button for "Show items only when the following is true"
    • In the first filter selection choose the date column you wish to filter on in the dropdown
    • In the second dropdown select "is greater than"
    • In the text box below it enter:    [Today]    (with the brackets)
    • Under that select the "And" radio button
    • Select the Event Type column in the first dropdown under where you clicked "And"
    • In the next dropdown select "is equal to"
    • Then type in your value of 1
    • Click "Show More Columns"
    • Keep the default of "or"
    • Select event type in the first dropdown
    • Then select "is equal to"
    • Then enter the value of 2
    • Click "Show More Columns"
    • Keep the default of "or"
    • Select event type in the first dropdown
    • Then select "is equal to"
    • Then enter the value of 3
    • Click OK

    I apologize if that's not what you're looking for.  I figured I may as well post it in case that's what you're trying to accomplish.

     

     

    Thursday, July 28, 2011 5:50 PM
  • Melissa,

    Thanks so much. I was filtering a view. I tried the code you suggested, but it didn't work. I had to change it to this:

    Start is less than [Today] AND Event Type = 1 OR

    Start is less than [Today] AND Event Type = 2 OR

    Start is less than [Today] AND Event Type = 3


    Carole
    • Proposed as answer by Rashu,Rahul Saturday, July 30, 2011 8:16 AM
    • Marked as answer by Mike Walsh FIN Wednesday, August 3, 2011 4:19 PM
    Friday, July 29, 2011 11:01 PM
  • Hi Carole,

    I'm glad you were able to find your solution.  Could you please post what version of SharePoint you are using (this will be helpful to others that come across your post looking for a similar solution).  My solution above was tested on MOSS 2007 Enterprise.

    Thank you,

    Melissa


    Moderator Note: In these forums we assume MOSS 2007 or WSS 3.0 unless otherwise stated. (So I'm locking the thread as the OP has her answer)
    • Edited by Mike Walsh FIN Wednesday, August 3, 2011 4:20 PM Moderator Note added
    Wednesday, August 3, 2011 3:05 PM