Retrieving Node Property Values
The =DCPROPERTY(dcids, property)
formula returns values associated with the given property Place DCIDs.
Note: Be sure to follow the instructions for Installing and Enabling the Sheets Add-On before using this formula.
Formula
=DCPROPERTY(dcids, property)
Required Arguments
dcids
: A list of Place nodes, identified by their DCIDs.property
: The property whose value you are interested in, such as “name” for the name of a node, or “typeOf” for the type of a node. If you aren’t sure what properties are available for a particular DCID, you can use the Data Commons Knowledge Graph. to look up the DCID of interest and see what properties it is associated with.
Returns
The values of the property label for the specified DCIDs.
Note: It’s best to minimize the number of function calls to
=DCPROPERTY(dcids, property)
by using a single call to get the names for a column of nodes. This is because a spreadsheet will make one call to a Google server per custom function call. If your sheet contains thousands of separate calls to=DCPROPERTY(dcids, property)
you can expect it to be slow and return with errors.
Examples
This section contains examples of using the =DCPROPERTY(dcids, property)
to return values associated with the given property Place DCIDs.
Example 1: Retrieve the Common Name of a Country by its DCID
To retrieve the name of a country by its DCID, perform the following steps:
- Place your cursor in the cell where you want to add a DCID. In this case, cell A1.
- Enter
country/CIV
for the country Ivory Coast. - Next, place your cursor in cell B2 and enter
=DCPROPERTY(A1, "name")
to retrieve the Ivory Coast country names in column B. - Note that the French and English spellings for Ivory Coast appear in column B.
Example 2: Retrieve the Order to which the Plant Austrobaileya Scandens Belongs
To retrieve the order to which the plant Austrobaileya Scandens belongs, perform the following steps:
- Place your cursor in the cell where you want to add a DCID. In this case, cell A1.
- Enter
dc/bsmvthtq89217
for the plant Austrobaileya Scandens. - Place your cursor in cell B2 and enter
=DCPROPERTY(A1, "order")
. - Note that the order Austrobaileyales appears in cell B2.
Example 3: Retrieve the Addresses of Stuyvesant High School in New York and Gunn High School in California
To retrieve the addresses of Stuyvesant High School in New York and Gunn High School in California, perform the following steps:
- Place your cursor in cell A1 and enter
nces/360007702877
for Stuyvesant Hight School in New York. - Place your cursor in cell A2 and enter
nces/062961004587
for Gunn High School in California. - Enter the formula
=DCPROPERTY(A1:A2, "address")
into cell B2 and the addresses of both high schools are populated in column B.
Error Responses
The =DCPROPERTY(dcids, property)
returns the value of the property label for the specified DCIDs. See the Examples section above for examples of positive responses.
If you pass a nonexistent property, an empty value is returned. For example, because the “nonexistent property” does not exist, no value is returned to cell B1 in the following sheet:
If you pass a bad DCID, an empty value is returned:
If you pass an empty DCID, an error is returned:
If you do not pass a required property argument, an error is returned: