How to *keep* duplicates in a filter?

Scenario: Several tiddlers have a myfield field. Most tiddlers have unique myfield values, but a few have identical and arbitrary values like myfield: foo, some have myfield: bar, etc.

How can I make a table that lists only those field values that appear in multiple tiddlers and, next to it, all tiddlers that have this field value, like so:

image

The only approach I can come up is problemtic because, for once, duplicate titles must be kept in the filters and I must also count them to insure they are indeed duplicates. But maybe this approach is off to begin with…?

Thanks!

I’m not sure how this will scale, performance-wise, but try this:

<table>
<$list filter="[each[myField]get[myField]] :filter[all[tiddlers]myField<currentTiddler>count[]compare:number:gt[1]]">
<tr>
<td><<currentTiddler>></td>
<td>

{{{ [myField<currentTiddler>] }}}

</td>
</tr>
</$list>
</table>
2 Likes

etardiff’s is probably better, but since I was also working on it, I’ll post mine which uses a variable instead of [all[tiddlers]] step:

<table><$list filter="[has[myfield]get[myfield]unique[]sort[]]" variable="fieldvalue"> <$list filter="[myfield<fieldvalue>count[]compare:number:gt[1]]">
<tr><td><<fieldvalue>> </td><td>{{{ [myfield<fieldvalue>] }}} </td></tr></$list></$list>
</table>
2 Likes

@etardiff and @Springer - thank you both! They both work, and it is quite educational to compare them side by side (…or, really, vertically):

<table>
<$list filter="[each[myField]get[myField]]
  :filter[all[tiddlers]myField<currentTiddler>count[]compare:number:gt[1]]">
<tr>
<td><<currentTiddler>></td>
<td>{{{ [myField<currentTiddler>] }}}</td>
</tr>
</$list>
</table>

<table>
<$list filter="[has[myField]get[myField]unique[]sort[]]" variable="fieldvalue"> 
<$list filter="[myField<fieldvalue>count[]compare:number:gt[1]]">
<tr><td><<fieldvalue>> </td>
<td>{{{ [myField<fieldvalue>] }}} </td>
</tr>
</$list>
</$list>
</table>

The main difference is that of a compound filter vs nested listwidgets.

Much appreciated.

2 Likes