I am looking for ways to select features in attribute table which have same values but in different column.
In the picture below as you can see "fid_2"
has values which match "fid"
but they are different features (shown by black arrow). Here I have manually selected the feature which match but I want to be able to select all three features like the one below automatically. Any ideas?
When "Select by expression" used
enter image description here
When I used the Field calculator
enter image description here
-
2Given the example it seems that an attribute join fid to fid_2 qgistutorials.com/en/docs/performing_table_joins.html might be helpful but be VERY careful with FIDs, they're transient. When joined a matched fid to fid_2 will have fully populated rows but an unmatched one will have empty joined columns. If there are more fields or more than one instance of a joined field the process becomes far more complicated.Michael Stimson– Michael Stimson2021年10月26日 04:44:44 +00:00Commented Oct 26, 2021 at 4:44
1 Answer 1
Use the "Select by expression" from the Selection Toolbar
with the following expression:
array_contains(
string_to_array(
concatenate_unique("fid_2")
),
"fid")
Usually fields like "id"
and "fid"
are integers, in this case use a slightly difference expression:
array_contains(
string_to_array(
concatenate_unique(
to_string("fid_2")
)
),
"fid")
It uses the following functions: array_contains()
, string_to_array()
, concatenate_unique()
, and to_string()
.
P.S. I do not really understand whether you need to select "fid"
in "fid_2"
, or vise versa.
-
It says the expression in invalid. Plus the picture shared is only a part of the selection, I have to do it for a lot of data.Anu Rai– Anu Rai2021年10月26日 04:57:55 +00:00Commented Oct 26, 2021 at 4:57
-
Please check the updates :)2021年10月26日 05:00:56 +00:00Commented Oct 26, 2021 at 5:00
-
I used the second expression which showed false for all. Did not do the selection I wanted. I wanted to select these in a bid to dissolve those features into one and did not want to do it manually. Any further help will be highly appreciated.Anu Rai– Anu Rai2021年10月26日 05:21:29 +00:00Commented Oct 26, 2021 at 5:21
-
That is weird. Can you please share a piece of your data or at least show how the above expression works/fails in your project for your layer?2021年10月26日 05:27:13 +00:00Commented Oct 26, 2021 at 5:27
-
1@Taras: proud to have an attribute bamed after you (OP's last screenshot)? ;-)Babel– Babel2021年10月26日 06:09:12 +00:00Commented Oct 26, 2021 at 6:09
Explore related questions
See similar questions with these tags.