I have a layer which I have set the primary symbology to 'Unique Values'. I have then used an expression which combines the values from two fields:
$feature.code + ' ' + $feature.name
The code and name fields are unique and I get the same number of items as simply classifying by just the code field or just the name field. However, when I don't use an expression only the visible items show in the legend. When I use the above expression, all of the items show in the legend, even those that aren't visible. How can I fix this?
In truth, I am only doing this so that the legend shows both the code and the name fields - so I would accept a solution that involves changing the label field (but not one by one - their are hundreds of items!)