locked
How do you enter a Compound Filter in Sharepoint 2007? RRS feed

  • Question

  •  

    I need to enter a filter like the following. What do I need to do to enter a compound filter like this?

    (Title = “Product” And Color = “Red”)
    
    Or
    
    (Title = “Product” And Color = “Green”)
    
    Or
    
    (Title = “Product” And Color = “Yellow”)

     


    Thanks! ~Indy
    Wednesday, December 14, 2011 12:27 PM

Answers

  • Hi,

    Please open the AllItems.aspx page of the list in SPD and convert it to XSLT Data View or you can create a Data View Web Part directly. Click Filter option in the Data View Common Data View Tasks, and in Filter Criteria window, select Add XSLT Filtering checkbox and click Edit beside. In Edit the XPath expression, type in following code and click OK.

    [(@Color='Yellow' or @Color='Red' or @Color='Green') and @Title='Product']

    In addition, you can set other filters you like by customizing the code.

    Thanks.


    Emir Liu

    TechNet Community Support

    Thursday, December 15, 2011 4:33 AM

All replies

  • Do you want these different permutations all within one view?  Or have you tried multiple views?  You can set one filter per column when defining them in the view creation field, with an AND/OR option available between the different ones used.
    Steven Andrews | SharePoint Professional | http://www.twitter.com/backpackerd00d | https://baron72.wordpress.com/
    Wednesday, December 14, 2011 1:19 PM
    Answerer
  • Hi Steven,

    Thanks for the quick reply.

    I need this in one view. As this is a compound filter, you can't use the normal filtering provided.

    This will NOT work for example:

     

    Title = "Product"
    
    and
    
    Color = "Yellow"
    
    or
    
    Color = "Red"
    
    or
    
    Color = "Green"

     

    Sharepoint will consider each of these filters independently, so I could get ALL Titles with the Color Red for instance.

    I need it to be a compound condition like this:

     

    Title = "Product" and Color = "Yellow"
    
    or
    
    Title = "Product" and Color = "Red"
    
    or
    
    Title = "Product" and Color = "Green"

     

    This will correctly all titles with "product" in colors that equal yellow, or red or green....and not other colors like blue...and not other titles.


    Thanks! ~Gone2TheDogs
    Wednesday, December 14, 2011 1:28 PM
  • I'm sure this is a common task. Does anyone have a suggestion on how to do this?

    Thanks!

     


    Thanks! ~Gone2TheDogs
    Wednesday, December 14, 2011 10:14 PM
  • Hi,

    Please open the AllItems.aspx page of the list in SPD and convert it to XSLT Data View or you can create a Data View Web Part directly. Click Filter option in the Data View Common Data View Tasks, and in Filter Criteria window, select Add XSLT Filtering checkbox and click Edit beside. In Edit the XPath expression, type in following code and click OK.

    [(@Color='Yellow' or @Color='Red' or @Color='Green') and @Title='Product']

    In addition, you can set other filters you like by customizing the code.

    Thanks.


    Emir Liu

    TechNet Community Support

    Thursday, December 15, 2011 4:33 AM
  • Thank you Emir. This is exactly what I needed!!!!  :-)

     


    Thanks! ~Gone2TheDogs
    Thursday, December 15, 2011 5:10 AM