1

I am trying to get all quantitative values of a given wd:* entry including the statements details (qualifiers?) - foremost the unit, since most numeric values are useless without it.

I was able to come up with the following query to get all quantitative values:

SELECT ?p ?property ?propertyLabel ?propertyDescription ?v WHERE {
  wd:Q1726 ?p ?v.
  ?property wikibase:propertyType wikibase:Quantity;
    wikibase:directClaim ?p.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?v
p property propertyLabel propertyDescription v
wdt:P2046 wd:P2046 area area occupied by an object 310.71

As you can see this is perfect to get the value of 310 km² as well as the labels and description of property you are looking for.

With the knowledge of the property being wd[t]:2046, I came up with a new query to get the value with quantifiers for it's best statement:

SELECT ?statement ?value ?valueLabel ?unit ?unitLabel WHERE {
  wd:Q1726 p:P2046 ?statement.
  ?statement psn:P2046 ?valuenode.
  ?valuenode wikibase:quantityAmount ?value.
  ?valuenode wikibase:quantityUnit ?unit.
  ?statement a wikibase:BestRank.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
statement value valueLabel unit unitLabel
wds:Q1726-33fec614-441a-a6c4-06cd-b79490a52c4b 310710000 310710000 wd:Q25343 square metre

However I have no idea how to join these two queries to relate ?v of the first one with ?statement of the second one. In the end what I'm looking for is to add a unit column to the first query. All examples and explanations I've seen regarding quantifiers are searching for a given property and I'm struggling to understand how to relate statement with statement/value-normalized/ and statement/value/ or how to filter for a property to be one of those.

Sebastian
  • 11
  • 1
  • https://mediawiki.org/wiki/Wikibase/Indexing/RDF_Dump_Format – Stanislav Kralin Jan 29 '23 at 18:28
  • `SELECT ?wd ?wdLabel ?wdDescription ?valAmount ?valUnitLabel { VALUES ?item { wd:Q1726 } ?item ?p ?stmt. ?stmt ?psv ?valNode. ?wd wikibase:propertyType wikibase:Quantity; wikibase:claim ?p ; wikibase:statementProperty ?ps ; wikibase:statementValue ?psv . ?valNode wikibase:quantityUnit ?valUnit ; wikibase:quantityAmount ?valAmount SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } ORDER BY (?wd) (?stmt) (?ps_)` would give you all direct quantity values with unit. – UninformedUser Jan 30 '23 at 07:56
  • for the statement qualifiers, you could just follow the `?ps` variable, similar to the query in https://stackoverflow.com/a/70609970/4744359 – UninformedUser Jan 30 '23 at 07:57

0 Answers0