Skip to content

Commit

Permalink
Rewrite procedures for sorting, using workaround (#493)
Browse files Browse the repository at this point in the history
* troubleshooting API

* Revert to gerund

Though the style guide says to just use imperatives, "get started" just sounds weird. Also this is more consistent with "troubleshooting"

* fixed egregiously out-of-date info and added mention of Sheets to the concepts doc

* overhaul Sheets index page

* fix few mis-wordings

* restore mention of Workspace Marketplace

* tweak procedure

* Revert "tweak procedure"

This reverts commit d35bc34.

* tweak procedure again

* rewording suggested by Julia

* removed reference to video which I removed, and correct column number

* rewrote sort step of sleep tutorial

* updated data to 2020

* tweak images

* small tweaks
  • Loading branch information
kmoscoe authored Sep 3, 2024
1 parent cafd60b commit de4b478
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
8 changes: 8 additions & 0 deletions api/sheets/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,11 @@ Here's a quick demo on using several of the Data Commons functions to get popula
Your spreadsheet should now look like this:

![Sheets first demo](/assets/images/sheets/home_page_demo.png){: height="400"}

### Sort data

Because the Data Commons add-on does not actually store values, but only formulas, in a sheet, you can't directly sort the data. To sort the data, you need to copy it as values to a new sheet and then sort as usual:

1. Select all the columns in the sheet and select **Edit** > **Copy**.
1. Select **Insert** > **Sheet** to create a new sheet.
1. Select **Edit** > **Paste special** > **Values only**. You can now sort each column as desired.
2 changes: 1 addition & 1 deletion api/sheets/tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Get familiar with the [Data Commons Google Sheets API](..) with these step-by-st

- [Analyze the COVID-19 pandemic](sheets_covid.html)
- [Obtain latitude information for country capitals in South America](sheets_latitude.html)
- [Sorting the CDC 500 cohort on sleep](sheets_sleep.html)
- [Analyze CDC 500 cities sleep health](sheets_sleep.html)
30 changes: 13 additions & 17 deletions api/sheets/tutorials/sheets_sleep.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
---
layout: default
title: Sheets CDC 500 Sleep Sorting
title: Sheets CDC 500 cities sleep health
nav_order: 2
parent: Tutorials
parent_url: /api/sheets/tutorials
grand_parent: Google Sheets
grand_parent_url: /api/sheets
---

# Sorting the CDC 500 cohort on sleep
# Analyze the CDC 500 cities for sleep health

## Introduction

The Data Commons API enables easy access to health data for the 500 cities the CDC has prioritized for public health information tracking. This tutorial will walk you through accessing and analyzing that information and scoring each of the cities according to adults residents’ excellence in sleep habits.
The Data Commons API enables easy access to health data for the 500 cities the U.S. Centers for Disease Control and Prevention (CDC) has prioritized for public health information tracking. This tutorial will walk you through accessing and analyzing that information and scoring each of the cities according to adults residents’ excellence in sleep habits, for the year 2020.

## Step 1: Setup
Pull up Google Sheets and create a new, blank spreadsheet. You can title it `Data Commons CDC 500 sleep analysis` or any other name of your choosing.

![](/assets/images/sheets/tutorials/sheets_sleep_tutorial_1.png)

To enable the Data Commons API in your spreadsheet, ensure that the Data Commons extension is installed and available under the Extensions tab in the main menu. Hover over the Data Commons menu item, then click on the Fill Place DCIDs option.
To enable the Data Commons API in your spreadsheet, ensure that the Data Commons extension is installed and available under the **Extensions** menu. Hover over the **Data Commons** menu item, then click on the **Fill place DCIDs** option.

![](/assets/images/sheets/tutorials/sheets_sleep_tutorial_2.png)

Expand All @@ -36,22 +36,18 @@ To get the names of these cities, enter `=DCGETNAME(B1:B500)` into cell C1. The

![](/assets/images/sheets/tutorials/sheets_sleep_tutorial_5.png)

## Step 3: Obtain the sleep health level for each city.
## Step 3: Obtain the sleep health level for each city
We will use the percentage of chronically restless residents in each city using the `DCGET` method with the statistical variable `Percent_Person_SleepLessThan7Hours`. (More information on statistical variables is available in the [glossary](https://docs.datacommons.org/glossary.html).) Enter `=DCGET(B1:B500, "Percent_Person_SleepLessThan7Hours", "2016")` into cell D1 in your spreadsheet. The output should look like this:

![](/assets/images/sheets/tutorials/sheets_sleep_tutorial_6.png)
![](/assets/images/sheets/tutorials/sheets_sleep_tutorial_6.png){: width="600"}

## Step 4: Sort on sleep score.
Data Commons has made a tutorial on sorting in Sheets available at <https://docs.datacommons.org/api/sheets/>. To summarize, the process of sorting on columns looks like this:
## Step 4: Sort on sleep score

- Obtain the desired data from Data Commons.
- Turn on filter views (in the Data dropdown, click "Filter views").
- Click the inverted triangle at the top of each column.
1. Select columns B, C, and D, and choose **Edit** > **Copy**.
1. Select **Insert** > **Sheet** to add a new sheet.
1. Select **Edit** > **Paste special** > **Values only**.
1. Select column C, click the down arrow, and select **Sort sheet Z to A**.

Follow the example in the video to sort your spreadsheet on the F column. Your final output should look like this:
Your final output should look like this:

![](/assets/images/sheets/tutorials/sheets_sleep_tutorial_7.png)

Note the added headers and resized column widths for increased clarity. Also, if you’re experiencing slow sorting in the sheet, consider replacing the method calls in the C and D columns with their values. To do this, copy the columns, then paste by value only into their original locations in the spreadsheet.

To further explore data from this tutorial, check out <https://docs.google.com/spreadsheets/d/1aSilceR2fZR-pTfMuilGebg9yDzOiR993bCtAk7GwlI/edit?usp=sharing>.
![sorted](/assets/images/sheets/tutorials/sheets_sleep_tutorial_7.png){: width="400"}
Binary file not shown.
Binary file modified assets/images/sheets/tutorials/sheets_sleep_tutorial_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/sheets/tutorials/sheets_sleep_tutorial_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit de4b478

Please sign in to comment.