5

I have a table where fields are a specific month of a year. And I just want to add a new field that is the sum of the months fields that are ticked. Practically speaking I need to know the duration of construction sites which are represented by an entity (one line is one site) by counting the months.

enter image description here

I know I could do that in Excel too but I still have trouble importing data properly so I'd rather just find an easy fix this time.

1
  • 1
    Well, what have you tried?
    – Erik
    Jul 16, 2021 at 7:36

1 Answer 1

4

Use Field calculator to calculate the number of ticked cells:

array_length (array_filter (map_avals( attributes( )),@element='x'))

Replace 'x' at the end with the string you use to "tick" the field. Works regardless of how many other attributes you have.

enter image description here

2
  • THANK YOU VERY MUCH FOR THIS QUICK AND EFFICIENT HELP!! :)
    – Noël
    Jul 16, 2021 at 16:15
  • 1
    You're welcome. As a new user, please be adviced that this side tries to avoid "thank you" messages. Instead, it encourages you to accept the answer and/or upvote it: click the checkmark right to the answer to accept it - see: gis.stackexchange.com/help/someone-answers Just click the checkmark, see here: meta.stackexchange.com/questions/5234/…
    – Babel
    Jul 16, 2021 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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