0

I have a SharePoint list and one of the columns is a Managed Metadata field for users to tag items with one or more tags. The users want a report that will allow them to filter by this keyword column.

So if I have

ID | Title          | Keywords
1  | Example 1 | Finance; Tax
2  | Example 2 | Corporate; Planning; Tax
3  | Example 3 | Personal

and I filter by Tax I should get the first two items returned. I have created a calculated column in my report so that the MMD field doesn't appear with the ID number in front of it.

Instead of 15#;Corporate;#21;#Planning;#35;#Tax I have Corporate, Planning, Tax but I cannot figure out how to dynamically populate the parameter without duplicates or how to filter fields with more than one tag. Surely I am missing something here?

0

This turned out to be quite complicated. But I had to access the SQL DB itself and select the Distinct values from the tags column to populate the parameter.

Then used custom code to loop through the tags and compare to each item selected in the parameter.

e.g. If my parameter was filtered by Tax item 1 and 2 would return but if I selected Tax and Personal to filter all 3 items would be displayed.

Public Function Contains(ByVal ItemToCheck As String, ByVal CommaValuesList As String, ByVal delimeter As Char) As Boolean
  Dim commaValues() As String = Split(CommaValuesList, delimeter, -1, CompareMethod.Text)
  Dim checkValues() As String = Split(ItemToCheck, delimeter, -1, CompareMethod.Text)

  For Each commavalue As String In commaValues
    For Each checkValue As String In checkValues
            If checkValue .ToLower.Trim = commavalue.ToLower.Trim Then
                    Return True
            End If
    Next
  Next

  Return False
End Function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.