I am trying to add an expression to a legend item in my print layout that auto-updates when values in the field change.

Essentially, I have a layer with a field which calculates the length of each feature and would like the print layout to display the sum of these lengths for all features.

Could someone point me in the right direction?

  • 1
    What have you tried? Where are you stuck? Should the value be calculated for all features, or only those visible in the map item?
    – Erik
    Jan 27, 2023 at 14:57
  • In the legend, I can open the properties for each entry, and there is the option to insert expression, however in the fields and values drop down in the expression editor, none of the fields from the layer appear so I can't use the sum function on them.
    – Mon
    Jan 27, 2023 at 15:02
  • 1
    Guessing as we don't have much more information, you might want to use get_feature(layer, attribute, value) and then attribute(feature, attribute_name)
    – Kasper
    Jan 27, 2023 at 20:04
  • Providing a project with sample data always helps 1) understanding the question 2) testing possible solutions
    – Babel
    Jan 29, 2023 at 10:23


Your Answer

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