query-7b097dccf7330c6438751169a97f25f4
Result elections table, which shows the historical results evolution of political parties in one city/municipality. Don't mind about the nice (or not) format. The problems I have are: User:Amadalvarez/election tableHi. I need to build a result table like intersection.party x year qualifier of each P991. It must be shown in its (P1114)quantity The values for table cells comes from the (the winner political parties in any election defined by the "select".(P991)successful candidate the values to show as a header are the collection of different values of all entries of To get all values I do:
Use at
- https://query.wikidata.org/sparql
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 ?item ?itemLabel ?year ?party ?partyLabel ?seats WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31 wd:Q152450;
    wdt:P1001 wd:Q1233527;
    p:P991 _:b56.
  _:b56 ps:P991 ?party;
    pq:P1114 ?seats.
  ?item wdt:P585 ?data. Bind(year(?data) as ?year)
  Filter (?seats > 0)
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?data")
  v2("?item"):::projected 
  v3("?party"):::projected 
  v1("?seats"):::projected 
  v5("?year"):::projected 
  a1((" "))
  c9(["wd:Q1233527"]):::iri 
  c3(["bd:serviceParam"]):::iri 
  c5(["#91;AUTO_LANGUAGE#93;,en"]):::literal 
  c7(["wd:Q152450"]):::iri 
  f0[["?seats > '0^^xsd:integer'"]]
  f0 --> v1
  subgraph s1["http://wikiba.se/ontology#label"]
    style s1 stroke-width:4px;
    c3 --"wikibase:language"-->  c5
  end
  v2 --"p:direct/P31"-->  c7
  v2 --"p:direct/P1001"-->  c9
  v2 --"p:P991"-->  a1
  a1 --"p:statement/P991"-->  v3
  a1 --"p:qualifier/P1114"-->  v1
  v2 --"p:direct/P585"-->  v4
  bind1[/"year-from-dateTime(?data)"/]
  v4 --o bind1
  bind1 --as--o v5