Nice challenge for Out Of the Box thinking where there are no Out of the Box answers
Programmers approach would we to use Two Loops
- One to loop all items and count the double ones
- And loop all items again to display an item or not
You can use Client Side Rendering for that; if you do all processing first you can built the HTML before it is displayed in the browser.
See: Displaying list with only unique values in title column
But..
you have to code some 30 lines of boilerplate code.. AND attach a JSlink to **every View* you want to use it.
If you don't mind a flash (displayed content is erased)
Out of the box with NO loops
.. well.. strictly speaking one loop... the original SharePoint code displaying a whole View
You can make each ListItem count itself and then check if its total count is > 1
In A Calculated Column (set to datatype=Number)
which executes some cute JavaScript(I haven't tested all browsers, works in Chrome and IE10)
Paste the Formula:
="<img src=/_layouts/images/blank.gif onload=""{"
&"var C,v='count_"
&[Task Name]
&"',w=window,TR=this;while(TR.tagName!='TR'){TR=TR.parentNode}"
&"C=w.cnt=w.cnt||{};"
&"C[v]=C[v]||0;"
&"C[v]++;"
&"_spYield(function(){TR.style.display=['none','inherit'][C[v]==1?0:1]},1);"
&"}"">"
- Each item displays a blank IMG to trigger JavaScript code (the SCRIPT tag is disabled by Microsoft)
- You can then built a JavaScript variable v with the value you want to check doubles for
Since this code is always executed for every ListItem we need some special bookkeeping of Global variables
- we check if a Global variable (object) cnt exists, use it or declare it (once) as a new object
- we check if the value exists in the cnt object (a previous occurence) or set the counter to 0
- then always add 1 to the count
At this stage you could hide double values if the counter is >1 .. but you want the reverse, so it is essential we count all items first.
- _spYield (declared in SP.js, but you won't find any blogs or documentation) makes JavaScript execution wait (something not possible out of the box with JavaScript)
We need this wait/delay because IMGs are loaded async, thus this code as well and we want to make sure all ListItems are processed/counted.. a yield/Wait of 1 millisecond seems to be enough
So once all ListItems are counted they execute their own function
- the executed function sets the display based on the counter,
- if the counter==1 we pick the 0th value in the text-array (hide)
- otherwise the 1th value (leave double values displayed)