Hi Michael,

Your wikidataQnumber is not an IRI that refers to the item of Wikidata.

Try:

PREFIX ira:<https://ir-authorities.wikibase.cloud/entity/>
PREFIX irp:<https://ir-authorities.wikibase.cloud/prop/direct/>
PREFIX wdt:<http://www.wikidata.org/prop/direct/>

SELECT ?person ?wikidataQNumber ?country
WHERE {
   ?person irp:P20 ira:Q174;         # is a human
           irp:P2 ?wikidataQNumber.  # wikidata identifier
          BIND(IRI(CONCAT("http://www.wikidata.org/entity/",?wikidataQNumber)) as ?q )
   OPTIONAL {
     SERVICE <https://query.wikidata.org/sparql> {
           ?q wdt:P27 ?country.
     }
   }
}

On Thu, Mar 9, 2023 at 8:51 PM Michael Lindsey <mlindsey@berkeley.edu> wrote:
Hi all,
I don't see my Monday post in the list archives, so I can't amend it.
I am attempting to bring a wikidata property, if present, into query results on my wikibase.cloud instance, but am getting nothing.
I have managed to create what I think is the simplest code to demonstrate my problem.
The below query ( https://tinyurl.com/2f8wzeoj ) executes without error.
Am I missing something, or can we not use Wikidata as a SERVICE?
Thanks for any insight you may have!
Michael Lindsey
UC Berkeley School of Law

PREFIX ira:<https://ir-authorities.wikibase.cloud/entity/>
PREFIX irp:<https://ir-authorities.wikibase.cloud/prop/direct/>
PREFIX wdt:<http://www.wikidata.org/prop/direct/>

SELECT ?person ?wikidataQNumber ?country
WHERE {
   ?person irp:P20 ira:Q174;                  # is a human
                  irp:P2 ?wikidataQNumber.  # wikidata identifier
   OPTIONAL {
     SERVICE <https://query.wikidata.org/sparql> {
           ?wikidataQNumber wdt:P27 ?country.
     }
   }
}
_______________________________________________
Wikibase Community User Group mailing list -- wikibaseug@lists.wikimedia.org
To unsubscribe send an email to wikibaseug-leave@lists.wikimedia.org


--
IP Squared | +31643053919 | @mzeinstra