query-74cd46f40e200d5e892882444c0939b1

rq turtle/ttl

This will remove all terms which have an end date - and thus only return ones which have not ended, which means those that are current. Some older historic data does not have end dates - but they also don't usually have start dates, so neatly don't show up here! In principle we could avoid the question of historic data by just asking for the current parliament (?ps ps:P39 wd:Q126063447) but this approach means it will also work after the next election - so we are future-proofing. Both approaches are valid. To find all sitting MPs in a specific party, you would set a specific value for ?party :

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT DISTINCT ?person WHERE
{
  ?person wdt:P31 wd:Q5 . ?person p:P39 ?ps . 
  ?ps ps:P39 ?term . ?term wdt:P279 wd:Q16707842 .
  ?ps pq:P580 ?start . ?ps pq:P768 ?seat . 
  ?ps pq:P4100 wd:Q9626 . 
  FILTER NOT EXISTS { ?ps pq:P582 ?end } .
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?end") v3("?person"):::projected v1("?ps") v6("?seat") v5("?start") v4("?term") c3(["wd:Q5"]):::iri c7(["wd:Q16707842"]):::iri c11(["wd:Q9626"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:qualifier/P582"--> e0v2 e0v2("?end"):::projected e0v1("?ps"):::projected end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c1 f0 --> v2 v1 --"p:qualifier/P582"--> v2 v3 --"p:direct/P31"--> c3 v3 --"p:P39"--> v1 v1 --"p:statement/P39"--> v4 v4 --"p:direct/P279"--> c7 v1 --"p:qualifier/P580"--> v5 v1 --"p:qualifier/P768"--> v6 v1 --"p:qualifier/P4100"--> c11