Is it possible to set an expression to determine if a legend item shows up based on an atlas name, variable or field?

I am generating an atlas that cycles through a series of iterations and shows different layers on each page. I have 4 different parameters and 15 different levels. It takes a bit of tinkering to format the legend entry to show up right, and the scales are constant for each parameter. I would like to have 4 legend entries that are formatted correctly, then select which of the 4 legend items shows up based on the Atlas features. If I just had 1 parameter, I could format the legend and keep it constant. I could also go through and add all 60 layers, format them and click the "only show features inside current atlas feature" button, but am hoping to avoid having to format each of the layers.

Is there a way to say show this legend item if [%"Parameter"%] = "XXX" and then have another legend item that shows up if [%"Parameter"%] = "YYY"? ([%"Parameter"%] is a atlas variable that is correctly printing the parameter in the current page.

1 Answer 1


There is no or at least I don't know standard integrated solution. There is a turnaround that work well.

You duplicate legend x4 and for each legend item you only keep the one legend item. Then you set a rule to make your legend item fully transparent or not based on your current atlas feature and a rule. This way you will get a different legend for your different atlas feature.

enter image description here

Other solution : do a 4 page for each atlas feature. Each page show the same atlas feature and different styling rules and legend and title. When you produce your atlas all is created well. (you must only select 4 of your 16 feature for atlas).

enter image description here

  • 1
    The first approach worked like a charm. Thank you Commented Sep 23, 2022 at 0:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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