Power Outage Data in Excel

To get power outage data into Excel, use Power Query's From Web connector in Advanced mode: request county counts from the PowerOutage.us v2 REST API as CSV with format=csv, send your key in an Authorization header, and load the result into an Excel table that refreshes every 15 minutes while the workbook is open. You need Excel for Windows (Microsoft 365, or Excel 2016 and later) to build and refresh it. This guide covers the dialog, the credential choice, keeping FIPS codes as text, moving the key into a parameter, and the refresh settings.

What you'll have

  • An Excel table with customers out, customers tracked, FIPS codes and last update time for every county in the states you choose.
  • FIPS codes kept as text with their leading zeros, so XLOOKUP and merges against store, branch or census lists match.
  • A refresh every 15 minutes while the workbook is open, and on opening the file.
  • The key in a single Power Query parameter you can blank before sharing a copy.

What you need

An API key (request one with the form below) and these endpoints. Full details are in the API reference.

EndpointMethodUsed forPackage
/outages/countiesGETCounty customersOut, customersTracked and lastUpdatedAt as CSV with format=csv, plus FIPS codes with include=fips.Core

Step 1: Connect with From Web in Advanced mode

On the Data tab, choose Get Data > From Other Sources > From Web, then select Advanced. Paste the URL below into the first URL part; change stateId to the states you need, using ids from /outages/states. Under HTTP request header parameters, type Authorization into the name box (it is not in the dropdown list, but the box accepts typing) and Bearer followed by your key into the value box, then choose OK. The key never goes in the URL: the API reads it only from this header. Excel has no secret store, so the header value is saved in the query, in plain text, inside the workbook; step 3 moves it to a parameter.

text
From Web > Advanced

URL parts:
  https://poweroutage.us/api/v2/outages/counties?stateId=44,45&format=csv&include=fips

HTTP request header parameters:
  Authorization        Bearer <YOUR_API_KEY>

Step 2: Choose Anonymous, then Transform Data

When Excel asks how to access the web content, choose Anonymous, pick https://poweroutage.us/ as the level to apply it to, and choose Connect. Anonymous is the right choice even though the API needs a key: the key travels in the header you just added, and Power Query refuses a custom Authorization header with any other credential type. When the preview of the CSV appears, choose Transform Data rather than Load, so you can set column types before anything reaches the sheet.

Step 3: Move the key into a parameter

In Power Query Editor, choose Home > Manage Parameters > New Parameter. Name it PowerOutageApiKey, set Type to Text, paste your key as the Current Value, and choose OK. The parameter is still saved in the workbook, and anyone with the file can read it in Queries & Connections, but the key now sits in one place: blank it before you send a copy, and replace it in one step when you rotate the key. Ask for a separate key restricted to the states this workbook covers, so a forwarded file exposes as little as possible.

Step 4: Replace the query with a typed version

Select the query, rename it Counties, open Home > Advanced Editor, and replace everything with this query. It reads the key from the parameter, which also takes the pasted key out of the query text, decodes the CSV as UTF-8 (Encoding = 65001) so accented place names come through, and sets each column type. Power Query guesses whole numbers for the fips.state, fips.county and fips.full columns, which drops leading zeros such as Alabama's 01; here they stay text. lastUpdatedAt arrives in UTC and is converted to this computer's local time, because worksheet cells have no time zone. Choose Done, then Home > Close & Load To, and load it as a Table on a new worksheet. Then check Data > Queries & Connections: PowerOutageApiKey should say Connection only. If Excel loaded it to a sheet, the key is sitting in a visible cell; delete that sheet, right-click the parameter, choose Load To, and pick Only Create Connection.

power query m
let
    // 44 is Florida and 45 is Georgia. List ids with GET /outages/states.
    Source = Csv.Document(
        Web.Contents(
            "https://poweroutage.us/api/v2/outages/counties?stateId=44,45&format=csv&include=fips",
            [Headers = [Authorization = "Bearer " & PowerOutageApiKey]]
        ),
        [Delimiter = ",", Encoding = 65001, QuoteStyle = QuoteStyle.Csv]
    ),
    Promoted = Table.PromoteHeaders(Source, [PromoteAllScalars = true]),
    Typed = Table.TransformColumnTypes(
        Promoted,
        {
            {"id", Int64.Type},
            {"name", type text},
            {"stateId", Int64.Type},
            {"countryCode", type text},
            {"customersTracked", Int64.Type},
            {"customersOut", Int64.Type},
            {"lastUpdatedAt", type datetimezone},
            {"fips.state", type text},
            {"fips.county", type text},
            {"fips.full", type text}
        }
    ),
    // Worksheet cells have no time zone, so show update times in this computer's local time
    LocalTime = Table.TransformColumns(
        Typed,
        {{"lastUpdatedAt", each DateTimeZone.RemoveZone(DateTimeZone.ToLocal(_)), type datetime}}
    )
in
    LocalTime

Step 5: Refresh every 15 minutes

On the Data tab, open Queries & Connections, right-click Counties, and choose Properties. Under Refresh control, check Refresh every and enter 15 minutes, check Refresh data when opening the file, and leave Enable background refresh on so you can keep working while it runs. The data updates every minute, so enter 1 or 2 if you need the latest numbers. Automatic refresh happens only while the workbook is open in Excel; a closed file stays as it was last saved.

Tips for Excel

  • Add your own formulas as new columns to the right of the loaded table; Excel keeps and fills them on every refresh. Column names with dots need an extra pair of brackets, as in =XLOOKUP([@[fips.full]], Stores[FIPS], Stores[Store]), and the lookup column must hold FIPS as text too.
  • For minutes since a county was last reported, add a column with =ROUND((NOW()-[@lastUpdatedAt])*1440, 0). Records are not zeroed when a utility stops reporting, so a large value means the count may be out of date.
  • If you picked another credential type by mistake, Excel rejects the header. Choose Data > Get Data > Data Source Settings, select https://poweroutage.us/, choose Edit Permissions, and under Credentials choose Edit and then Anonymous.
  • Key SUMIFS, XLOOKUP and PivotTable rows on id or fips.full. The same county name turns up in many states, so a lookup on name can return the wrong one. A row named Unknown with empty FIPS cells counts customers a utility did not assign to any county: include it in state totals, and expect it to miss in FIPS lookups.
  • Each refresh makes one request. If the API answers 429, Power Query retries on its own and waits the Retry-After seconds first.

Used by

Related integrations

FAQ

Here are some commonly asked questions

Request API access

Tell us what you're building and we'll set you up with a trial key.