query-e52d42fb5614035e62f4d3ad0a153270

rq turtle/ttl

Gender balance in Swedish parliamentI want to create a line chart with the proportion of men vs women in the Swedish parliament. It could either be two lines with the absolute counts, or a single line showing the ratio. Here's what I've got so far.

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 ?startYear ?sexLabel (COUNT(?item) as ?count)
WHERE 
{
  ?item wdt:P31 wd:Q5 .
  ?item p:P39 ?positionStatement .
  ?positionStatement ps:P39 wd:Q10655178 .

  ?positionStatement pq:P580 ?start .
  BIND(YEAR(?start) AS ?startYear ) .
  ?item wdt:P21 ?sex .

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?startYear ?sexLabel
ORDER BY ?startYear ?sexLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?count") v3("?item"):::projected v4("?positionStatement") v6("?sex") v2("?sexLabel"):::projected v5("?start") v6("?startYear"):::projected c9(["bd:serviceParam"]):::iri c2(["wd:Q5"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal c5(["wd:Q10655178"]):::iri v3 --"p:direct/P31"--> c2 v3 --"p:P39"--> v4 v4 --"p:statement/P39"--> c5 v4 --"p:qualifier/P580"--> v5 bind0[/"year-from-dateTime(?start)"/] v5 --o bind0 bind0 --as--o v6 v3 --"p:direct/P21"--> v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end bind2[/"count(?item)"/] v3 --o bind2 bind2 --as--o v7