This is a useful expression. But I'm finding some very random behavior with it.
The number of items matched is quite random. If I enter the expression in the search field, I get, say 16 Artists. If I hit enter in the search field to leave that box, the number of artists changes to 15. If I click "All Artists" in my Artists pane, I get 12.
Each time I use the expression, some random selection of items is returned.
And this causes some selections, or say, some artist, to return no results in the file list.
Perhaps you wanted Album Artist (auto) instead of Album Artist in the ~dup modifier?