query-236479965e7c4d458c36f001eb171d7f

rq turtle/ttl

# # generate all members serving on a specific date

see https://www.wikidata.org/wiki/Wikidata:WikiProject_British_Politicians

as of Feb 2019 this query will work comprehensively for any date since the 1886 election

including, where known, constituency, party, start & end dates, election, & reason term ended

1886 onwards = data precise to the day (a few minor exceptions wrt resignation dates etc)

(taken from Historic Hansard/MySociety then manually cleaned & validated)

1832-1886 = data from Historic Hansard but not yet validated, known to be somewhat incomplete

1386-1421, 1509-1604 = can only say "served at some point during the term" so

there will be some ambiguities (note last column for relevant data)

data for earliest periods is taken from History of Parliament but due to gaps

in the historical record is inevitably not complete - eg 1401 has only 40 MPs.

1640-1832 is completely blank, and 1421-1509, 1604-1640 are v patchy.

To run this query, change the date ("2016-05-10T00:00:00Z") below - keep the same format

then scroll down and click the blue [>] button to the lower left

SELECT DISTINCT ?item ?itemLabel ?constituencyLabel ?partyLabel ?start ?electionLabel ?end ?endcauseLabel ?noteLabel where { # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # sub in value here # # # # bind(("2016-05-10T00:00:00Z"^^xsd:dateTime) as ?date) . # # # # # # sub in value here # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ?item p:P39 ?positionStatement . ?positionStatement ps:P39 ?term . { ?term wdt:P279 wd:Q16707842 } union { ?term wdt:P279 wd:Q18015642 } union { ?term wdt:P279 wd:Q18018860 } OPTIONAL { ?positionStatement pq:P768 ?constituency . } OPTIONAL { ?positionStatement pq:P4100 ?party . } OPTIONAL { ?positionStatement pq:P2715 ?election . } OPTIONAL { ?positionStatement pq:P1534 ?endcause . } OPTIONAL { ?positionStatement pq:P580 ?start . } OPTIONAL { ?positionStatement pq:P582 ?end . } OPTIONAL { ?positionStatement pq:P793 ?note . } ?term wdt:P571 ?termstart . optional { ?term wdt:P576 ?termend . } filter (COALESCE(?start, ?termstart) <= ?date ) . filter (COALESCE(?end, ?termend, NOW()) >= ?date ) . # use qualifier dates; if not known use term dates; if no end date use now SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' } } order by desc(?start) ?end

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
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/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# # # generate all members serving on a specific date
#
# see https://www.wikidata.org/wiki/Wikidata:WikiProject_British_Politicians
# as of Feb 2019 this query will work comprehensively for any date since the 1886 election
# including, where known, constituency, party, start & end dates, election, & reason term ended
#
# 1886 onwards = data precise to the day (a few minor exceptions wrt resignation dates etc)
#                (taken from Historic Hansard/MySociety then manually cleaned & validated) 
# 1832-1886 = data from Historic Hansard but not yet validated, known to be somewhat incomplete
# 1386-1421, 1509-1604 = can only say "served at some point during the term" so 
#                        there will be some ambiguities (note last column for relevant data)
# 
# data for earliest periods is taken from History of Parliament but due to gaps
# in the historical record is inevitably not complete - eg 1401 has only 40 MPs.
# 
# 1640-1832 is completely blank, and 1421-1509, 1604-1640 are v patchy. 
#
# To run this query, change the date ("2016-05-10T00:00:00Z") below - keep the same format
# then scroll down and click the blue [>] button to the lower left

SELECT DISTINCT ?item ?itemLabel ?constituencyLabel ?partyLabel ?start ?electionLabel ?end ?endcauseLabel ?noteLabel
where {
  # # # #     # # # #     # # # # #
  # # # # #     # # # #     # # # # # 
  # # # # # # sub in value here # # # # 
    bind(("2016-05-10T00:00:00Z"^^xsd:dateTime) as ?date) . 
  # # # # # # sub in value here # # # #
  # # # # #     # # # #     # # # # #
  # # # #     # # # #     # # # # #
  ?item p:P39 ?positionStatement . ?positionStatement ps:P39 ?term . 
  { ?term wdt:P279 wd:Q16707842 } union { ?term wdt:P279 wd:Q18015642 } union { ?term wdt:P279 wd:Q18018860 } 
  OPTIONAL { ?positionStatement pq:P768 ?constituency . }
  OPTIONAL { ?positionStatement pq:P4100 ?party . }
  OPTIONAL { ?positionStatement pq:P2715 ?election . }
  OPTIONAL { ?positionStatement pq:P1534 ?endcause . }
  OPTIONAL { ?positionStatement pq:P580 ?start . }
  OPTIONAL { ?positionStatement pq:P582 ?end . }
  OPTIONAL { ?positionStatement pq:P793 ?note . }
  ?term wdt:P571 ?termstart . optional { ?term wdt:P576 ?termend . }
  filter (COALESCE(?start, ?termstart) <= ?date ) . filter (COALESCE(?end, ?termend, NOW()) >= ?date ) .
  # use qualifier dates; if not known use term dates; if no end date use now
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} order by desc(?start) ?end

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v9("?constituency") v6("?date") v11("?election") v2("?end"):::projected v12("?endcause") v6("?item"):::projected v13("?note") v10("?party") v7("?positionStatement") v1("?start"):::projected v8("?term") v3("?termend") v5("?termstart") c6(["wd:Q18018860"]):::iri c4(["wd:Q16707842"]):::iri c19(["en"]):::literal c17(["bd:serviceParam"]):::iri c5(["wd:Q18015642"]):::iri f0[["?end?termendNOW() >= ?date"]] f0 --> v2 f0 --> v3 f0 --> v6 f1[["?start?termstart <= ?date"]] f1 --> v1 f1 --> v5 f1 --> v6 bind2[/"'2016-05-10T00:00:00Z^^xsd:dateTime'"/] bind2 --as--o v6 v6 --"p:P39"--> v7 v7 --"p:statement/P39"--> v8 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v8 --"p:direct/P279"--> c6 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v8 --"p:direct/P279"--> c5 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v8 --"p:direct/P279"--> c4 end union0r <== or ==> union0l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:qualifier/P768".-> v9 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:qualifier/P4100".-> v10 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:qualifier/P2715".-> v11 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:qualifier/P1534".-> v12 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:qualifier/P580".-> v1 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:qualifier/P582".-> v2 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:qualifier/P793".-> v13 end v8 --"p:direct/P571"--> v5 subgraph optional7["(optional)"] style optional7 fill:#bbf,stroke-dasharray: 5 5; v8 -."p:direct/P576".-> v3 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c17 --"wikibase:language"--> c19 end