query-35646bb46521244ab1c09452682f24ab
Trying to add the percent to the ?titleHello! I'm trying to add the ?percent to the ?title, but can't get it with concat. Can someone help me, please?
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 bd: <http://www.bigdata.com/rdf#>
SELECT
?city
?cityLabel
(concat('% ', ?percent) as ?ehuneko)
(?city as ?id)
(SAMPLE(?fill) as ?fill)
(concat('[[:eu:', ?cityLabel, ']]') as ?title)
WHERE {
?item wdt:P361 wd:Q30594119.
?item wdt:P1831 ?total_voters .
?item wdt:P1868 ?active_voters.
?item wdt:P1001 ?city.
BIND (100*?active_voters/?total_voters AS ?percent) .
BIND(
if(?percent>= 90, '#610604',
if(?percent>= 80, '#994910',
if(?percent>= 70, '#D0B01F',
if(?percent>= 60, '#CBF13F',
if(?percent>= 50, '#ABF97A',
if(?percent>= 40, '#B1FFB3', '#a6a6a6')))))
) as ?fill).
SERVICE wikibase:label { bd:serviceParam wikibase:language 'eu'. }
} GROUP BY ?city ?cityLabel ?percent
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?active_voters")
v4("?city"):::projected
v7("?ehuneko")
v9("?fill"):::projected
v8("?id")
v1("?item")
v5("?percent"):::projected
v9("?title")
v2("?total_voters")
c2(["wd:Q30594119"]):::iri
c9(["eu"]):::literal
c7(["bd:serviceParam"]):::iri
v1 --"wdt:P361"--> c2
v1 --"wdt:P1831"--> v2
v1 --"wdt:P1868"--> v3
v1 --"wdt:P1001"--> v4
bind0[/"'100^^xsd:integer' * ?active_voters / ?total_voters"/]
v3 --o bind0
v2 --o bind0
bind0 --as--o v5
bind1[/"if(?percent >= '90^^xsd:integer','#610604',if(?percent >= '80^^xsd:integer','#994910',if(?percent >= '70^^xsd:integer','#D0B01F',if(?percent >= '60^^xsd:integer','#CBF13F',if(?percent >= '50^^xsd:integer','#ABF97A',if(?percent >= '40^^xsd:integer','#B1FFB3','#a6a6a6'))))))"/]
v5 --o bind1
bind1 --as--o v9
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end
bind3[/"concat('% ',?percent)"/]
v5 --o bind3
bind3 --as--o v7
bind4[/"?city"/]
v4 --o bind4
bind4 --as--o v8
bind5[/"sample(?fill)"/]
v9 --o bind5
bind5 --as--o v9
bind6[/"concat('#91;#91;:eu:',?cityLabel,'#93;#93;')"/]
null --o bind6
bind6 --as--o v9