1

Does anyone have an idea on "an expression to selection within subsets of vector layer in qgis"? Qgis has “Random selection within subset” to select randomly but I have to select within subset with the expression where a condition is:

WHEN case there are more than one class, then select only one '1', if there is no '1' then select '2', if there is no '1' & '2' then select a '3'.

amy points layer's attributen

  • where is your remarks count ? – snaileater Feb 13 at 8:51
  • #snaileater, I recently edited the question – Kapildev adhikari Feb 13 at 9:41
  • You seem just trying to calculate minimum class value for each subset group. I would suggest to try minimum("class", group_by:="subset")......Probably I am just reading at its face value; I don't know. – Kazuhito Feb 13 at 12:31
  • @Kazuhito, I am trying to select only one value per one subset, as shown in the picture; subset 2 has 5 values (3,3,2,1,2) from them I just trying to select the row that has value 1. Do you have an idea about it? – Kapildev adhikari Feb 13 at 17:14
2

If you want to get the minimum class value for each subset - as Kazuhito decifers - your can also use a Virtuel Layer (of the Datasource Manager) in QGIS:

select someothercolums, min(class), subset   
from test
group by subset;
  • Thank you #Jakob, WHEN case if there is class 1&2&3 then select only '1', if there are class 2&3 then select only '2', if there is class 3 then select only '3' And I am trying to select only one value per one subset, like subset 1 has 10 values (3,3,1,2,1,2,2,3,2) from them I just trying to select the row that has value 1. – Kapildev adhikari Feb 14 at 5:42
  • My virtual layer selects the minimum class value of each subset group. Is this not what you want as result? – Jakob Feb 14 at 8:53
  • How to perform this task #Jakob? Virtual Layer (of the Datasource Manager) in QGIS: select someothercolums, min(class), subset from test group by subset; – Kapildev adhikari Feb 14 at 8:58
  • In QGIS press Ctrl + L goto Virtual Layer and add the sql code, drop the someothercolumns text.... – Jakob Feb 14 at 10:20
  • #Jakob, Virtual Layer displays the following error; Referenced table test in query not found. – Kapildev adhikari Feb 14 at 10:41

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.