query-bcba3ae8dc766b572272fa6d1ad0a3cf

rq turtle/ttl

What were the most common reasons by decade to leave Parliament?

Use at

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#>
select (str(?decade) as ?dec) (count(distinct ?ps) as ?count) ?causeLabel   where
{
  ?mp p:P39 ?ps . ?ps ps:P39 ?term . ?term wdt:P279 wd:Q16707842 . 
  ?ps pq:P582 ?pend . filter not exists { ?mp p:P39 ?ps2 . ?ps2 ps:P39 ?term . ?ps2 pq:P580 ?pend } 
  # not new term starting same day - ie left Parliament
  ?ps pq:P1534 ?cause . 
  filter not exists { ?ps pq:P1534 wd:Q741182 } # not dissolution
  filter not exists { ?ps pq:P1534 wd:Q7649223 } # not suspension
  filter not exists { ?ps pq:P1534 wd:Q35855188 } # tofix
  filter not exists { ?ps pq:P1534 wd:Q36345696 } # tofix
  filter not exists { ?ps pq:P1534 wd:Q30580660 } # tofix
  filter not exists { ?ps pq:P1534 wd:Q52084147 } # tofix
  filter not exists { ?ps pq:P1534 wd:Q35867887 } # tofix
  bind(year(?pend) as ?year) . filter(?year >= 1880) . bind((floor(?year/10)*10) as ?decade) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} group by ?causeLabel ?decade order by ?causeLabel
#defaultView:BarChart

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?cause") v1("?causeLabel"):::projected v11("?count") v10("?dec") v9("?decade"):::projected v4("?mp") v7("?pend") v3("?ps"):::projected v5("?ps2") v6("?term") v9("?year") c9(["wd:Q741182"]):::iri c14(["wd:Q16707842"]):::iri c5(["wd:Q30580660"]):::iri c6(["wd:Q36345696"]):::iri c3(["wd:Q35867887"]):::iri c8(["wd:Q7649223"]):::iri c7(["wd:Q35855188"]):::iri c17(["bd:serviceParam"]):::iri c4(["wd:Q52084147"]):::iri c19(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["?year >= '1880^^xsd:integer'"]] f0 --> v9 f1[["not "]] subgraph f1e0["Exists Clause"] e0v1 --"p:qualifier/P1534"--> e0c2 e0v1("?ps"):::projected e0c2(["wd:Q35867887"]):::iri end f1--EXISTS--> f1e0 f1 --> v3 f1 --> c2 f1 --> c3 v3 --"p:qualifier/P1534"--> c3 f2[["not "]] subgraph f2e1["Exists Clause"] e1v1 --"p:qualifier/P1534"--> e1c2 e1v1("?ps"):::projected e1c2(["wd:Q52084147"]):::iri end f2--EXISTS--> f2e1 f2 --> v3 f2 --> c2 f2 --> c4 v3 --"p:qualifier/P1534"--> c4 f3[["not "]] subgraph f3e2["Exists Clause"] e2v1 --"p:qualifier/P1534"--> e2c2 e2v1("?ps"):::projected e2c2(["wd:Q30580660"]):::iri end f3--EXISTS--> f3e2 f3 --> v3 f3 --> c2 f3 --> c5 v3 --"p:qualifier/P1534"--> c5 f4[["not "]] subgraph f4e3["Exists Clause"] e3v1 --"p:qualifier/P1534"--> e3c2 e3v1("?ps"):::projected e3c2(["wd:Q36345696"]):::iri end f4--EXISTS--> f4e3 f4 --> v3 f4 --> c2 f4 --> c6 v3 --"p:qualifier/P1534"--> c6 f5[["not "]] subgraph f5e4["Exists Clause"] e4v1 --"p:qualifier/P1534"--> e4c2 e4v1("?ps"):::projected e4c2(["wd:Q35855188"]):::iri end f5--EXISTS--> f5e4 f5 --> v3 f5 --> c2 f5 --> c7 v3 --"p:qualifier/P1534"--> c7 f6[["not "]] subgraph f6e5["Exists Clause"] e5v1 --"p:qualifier/P1534"--> e5c2 e5v1("?ps"):::projected e5c2(["wd:Q7649223"]):::iri end f6--EXISTS--> f6e5 f6 --> v3 f6 --> c2 f6 --> c8 v3 --"p:qualifier/P1534"--> c8 f7[["not "]] subgraph f7e6["Exists Clause"] e6v1 --"p:qualifier/P1534"--> e6c2 e6v1("?ps"):::projected e6c2(["wd:Q741182"]):::iri end f7--EXISTS--> f7e6 f7 --> v3 f7 --> c2 f7 --> c9 v3 --"p:qualifier/P1534"--> c9 f8[["not "]] subgraph f8e7["Exists Clause"] e7v1 --"p:P39"--> e7v2 e7v2 --"p:statement/P39"--> e7v3 e7v2 --"p:qualifier/P580"--> e7v4 e7v1("?mp"):::projected e7v4("?pend"):::projected e7v2("?ps2"):::projected e7v3("?term"):::projected end f8--EXISTS--> f8e7 f8 --> v4 f8 --> c10 f8 --> v5 f8 --> c11 f8 --> v6 f8 --> c12 f8 --> v7 v4 --"p:P39"--> v5 v5 --"p:statement/P39"--> v6 v5 --"p:qualifier/P580"--> v7 v4 --"p:P39"--> v3 v3 --"p:statement/P39"--> v6 v6 --"p:direct/P279"--> c14 v3 --"p:qualifier/P582"--> v7 v3 --"p:qualifier/P1534"--> v8 bind9[/"year-from-dateTime(?pend)"/] v7 --o bind9 bind9 --as--o v9 bind10[/"numeric-floor(?year / '10^^xsd:integer') * '10^^xsd:integer'"/] v9 --o bind10 bind10 --as--o v9 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c17 --"wikibase:language"--> c19 end bind12[/"str(?decade)"/] v9 --o bind12 bind12 --as--o v10 bind13[/"count(?ps)"/] v3 --o bind13 bind13 --as--o v11