Filtering lists by count since formulas to check logic on multiple line items isn't possible? RRS feed

  • Question

  • I have an InfoPath form library where the primary purpose is for users to manage a document through a series of approvals.  Once the document reaches a final stage, it hangs out in the library for 1 - 3 years.  The issue is the that approved documents are hindering what users really need to focus on, which are the non-finished items.  I cannot filter by the completed status only...since then the user would have no indication that the review of that document number were finally complete. 

    Ideally I'd like to be able to use a COUNTIF formula to say "COUNTIF SOP Number = SOP Number" to find all the occurrences of that item, but since that doesn't seem possible.  Could I filter by COUNT?

    For example, "if Count = 1 and Status contains Approved then hide / filter" this record out of the list.   

    Monday, April 23, 2012 5:33 PM


  • Hi stephaniettt,

    As far as I know, it is difficult to achieve it with filter your count column. So, I suggest you create a column with number. Then you can use object module as the following code, put every count of group in your number column.

      SPSite site = new SPSite("http://jack-7716f30e37:2012/personal/Test/");
                using (SPWeb Web = site.OpenWeb())
                    site.AllowUnsafeUpdates = true;
                    Web.AllowUnsafeUpdates = true;
                    Web.AllowUnsafeUpdates = true;
                    SPList list = Web.Lists["YourList"];
                    foreach (SPListItem item in list.Items)
                        SPQuery query = new SPQuery();
                        query.Query = " <Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + item["Title"] + "</Value></Eq></Where>";
                        SPListItemCollection items = list.GetItems(query);
                        if (items.Count > 1)
                            item["YourColumnNumber"] = items.Count;

    Then you can filter your document library with your status and your column with number.



    Friday, April 27, 2012 8:29 AM