query-bf0a5e72bd8d282a6a6e7191ba018cf7
population chartI wanted to create a query that gives my the population of a certain object by year with male, female and whole population. I got that far, that i get a table with all the values that i need. as soon as i use ?year the chart starts with year zero and no explanation can be found. also i dont get it to show me all values in the chart. there is a zoo of examples and docs but its very difficult to find something helpful.
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
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#>
#defaultView:LineChart
SELECT ?point_in_time ?population ?malePopulation ?femalePopulation WHERE {
{
wd:Q661700 p:P1082 _:wp.
_:wp ps:P1082 ?population.
_:wp pq:P585 ?point_in_time.
BIND(YEAR(?point_in_time) AS ?Jahr)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de". }
}
UNION
{
wd:Q661700 p:P1540 _:mp.
_:mp ps:P1540 ?malePopulation.
_:mp pq:P585 ?point_in_time.
}
UNION
{
wd:Q661700 p:P1539 _:fp.
_:fp ps:P1539 ?femalePopulation.
_:fp pq:P585 ?point_in_time.
}
}
ORDER BY ?point_in_time
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?Jahr")
v5("?femalePopulation"):::projected
v4("?malePopulation"):::projected
v1("?point_in_time"):::projected
v2("?population"):::projected
a1((" "))
a2((" "))
a3((" "))
c8(["#91;AUTO_LANGUAGE#93;,de"]):::literal
c6(["bd:serviceParam"]):::iri
c1(["wd:Q661700"]):::iri
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;
c1 --"p:P1539"--> a3
a3 --"p:statement/P1539"--> v5
a3 --"p:qualifier/P585"--> v1
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
c1 --"p:P1540"--> a2
a2 --"p:statement/P1540"--> v4
a2 --"p:qualifier/P585"--> v1
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
c1 --"p:P1082"--> a1
a1 --"p:statement/P1082"--> v2
a1 --"p:qualifier/P585"--> v1
bind0[/"year-from-dateTime(?point_in_time)"/]
v1 --o bind0
bind0 --as--o v3
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c6 --"wikibase:language"--> c8
end
end
union0r <== or ==> union0l
end