query-236479965e7c4d458c36f001eb171d7f
# # 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
- https://query.wikidata.org/sparql
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