2

I create a report from attribute table. At one column I have a name of a street, at second column I have a number. Relation between street and a number is one-to-many. Is there a function to show at the report table name of a street only for biggest number or alternativelly group the column with name of a street the same way it is possible in MS excel, as shown at the picture below?

enter image description here

asked Jun 24, 2021 at 11:52
2
  • 1
    I need to use a function, because I create a report. Also, I need to be able to update a table simply. Commented Jun 24, 2021 at 12:17
  • Please, correct me if I understand you question the wrong way, but you can try the maximum() i.e. maximum("number", group_by:="Street") and the sum() i.e. sum("number", group_by:="Street") functions Commented Jun 24, 2021 at 12:21

1 Answer 1

1

Use this expression:

if (
 maximum( number,"street" )=
 attribute( get_feature_by_id (@layer, $id), 'number'),
 street,
 ''
)

Screenshot: I used the same values as in your screenshot, see the result: enter image description here

answered Jun 24, 2021 at 12:18
3
  • Thank you. I have "NULL" in some street fields. What is incorrect on function if("street" IS NULL, ' ',(if ( maximum( number,"street" )= attribute( get_feature_by_id (@layer, $id), 'number'), street, '' ))? Commented Jun 24, 2021 at 13:48
  • You have simply forgot one closing bracket ) at the end. If you have a NULL value, result will be NULL as well Commented Jun 24, 2021 at 13:57
  • But you don't need any special if-clause for NULL, the expression from my solution works well even for NULL values. Commented Jun 24, 2021 at 14:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.