Export · Microsoft Power BI

Build Power BI reports with NowMetrix data

Import NowMetrix metrics with Power Query, create a first report in Power BI Desktop, and publish the dataset for controlled sharing and scheduled updates.

How the connection works

The connection has two optional stages:

NowMetrix REST API → Power Query → Power BI Desktop → optional Power BI Service
  • Power BI Desktop creates the query, data model, and report.
  • Power BI Service publishes the report for browser access, sharing, and scheduled refresh.

The prepared example imports the last 30 available daily rows from /v1/overview. Every row includes the date, tracker, tracker timezone, pageviews, and visits.

Power BI imports a snapshot when the semantic model refreshes. It does not maintain a permanent live connection to NowMetrix and does not send NowMetrix values to Google Analytics.

Before you start

You need:

  • a NowMetrix account with REST API access,
  • access to the tracker you want to report on,
  • Microsoft Power BI Desktop for creating the report, and
  • an appropriate Power BI account and workspace if you want to publish or schedule refreshes.
Power BI Desktop is a Windows application. If you work on macOS, create the report in a managed Windows virtual machine, through a remote Windows environment, or with help from a colleague who has Power BI Desktop. Published reports can then be viewed in a web browser.

Power BI licensing, workspace permissions, and available refresh frequencies are managed by Microsoft and your organization's administrator. You can complete the Desktop setup without publishing the report.

1. Create a dedicated API key

  1. Sign in to NowMetrix.
  2. Open Settings → API.
  3. Create a new key labeled Microsoft Power BI.
  4. Copy the complete key immediately. It is shown only once.
  5. Note the tracker ID for the website you want to import.
Placeholder Replace with Example
nm_YOUR_KEY Your complete NowMetrix API key nm_…
TRACKER_ID The tracker ID to import news-example-com
Use a separate key for this report. If the PBIX file or Power BI workspace is ever exposed, you can revoke that key without interrupting Excel, Google Sheets, or another integration.

2. Create a blank query in Power BI Desktop

  1. Open Power BI Desktop and create a blank report.
  2. Select Home → Get data → Blank query. If it is not listed, select Get data → More and search for Blank query.
  3. Power Query Editor opens with a new query.
  4. Select Home → Advanced Editor.

Do not choose the basic Web dialog for this example. The Advanced Editor is used because NowMetrix requires a Bearer authorization header and the response must be converted from JSON into table rows.

3. Paste the prepared Power Query

  1. Remove the existing content from the Advanced Editor.
  2. Paste the complete query below.
  3. Replace nm_YOUR_KEY and TRACKER_ID in the first two lines.
  4. Keep both values inside quotation marks.
  5. Select Done.
let
    ApiKey = "nm_YOUR_KEY",
    TrackerId = "TRACKER_ID",

    Response = Json.Document(
        Web.Contents(
            "https://api.nowmetrix.com",
            [
                RelativePath = "v1/overview",
                Query = [
                    site = TrackerId,
                    days = "30"
                ],
                Headers = [
                    Authorization = "Bearer " & ApiKey,
                    Accept = "application/json"
                ],
                Timeout = #duration(0, 0, 0, 30)
            ]
        )
    ),

    DailyRows = if List.IsEmpty(Response[daily]) then
        #table(type table [date = text, pageviews = Int64.Type, visits = Int64.Type], {})
    else
        Table.FromRecords(Response[daily]),

    AddTracker = Table.AddColumn(
        DailyRows,
        "tracker",
        each Response[site],
        type text
    ),
    AddTimezone = Table.AddColumn(
        AddTracker,
        "timezone",
        each Response[timezone],
        type text
    ),
    ReorderedColumns = Table.ReorderColumns(
        AddTimezone,
        {"date", "tracker", "timezone", "pageviews", "visits"}
    ),
    TypedColumns = Table.TransformColumnTypes(
        ReorderedColumns,
        {
            {"date", type date},
            {"tracker", type text},
            {"timezone", type text},
            {"pageviews", Int64.Type},
            {"visits", Int64.Type}
        }
    )
in
    TypedColumns

The query uses a fixed base URL together with RelativePath and Query. This keeps the source predictable for later refreshes and sends the API key only in the HTTPS Authorization header.

4. Confirm the data source credentials

Power BI may ask how it should connect to https://api.nowmetrix.com.

  1. Choose Anonymous.
  2. Apply the setting to https://api.nowmetrix.com.
  3. Select Connect.
  4. If prompted for a privacy level, select the level required by your organization. Private provides the strictest separation from other data sources.
The connection is not anonymous to NowMetrix. Anonymous tells Power BI not to add a second Microsoft credential method; the query already authenticates with the NowMetrix API key in its Bearer header.

5. Load and verify the semantic model

  1. Wait until the query preview shows date, tracker, timezone, pageviews, and visits.
  2. Rename the query to NowMetrix Daily.
  3. Select Home → Close & Apply.
  4. Open the Data view and confirm that rows and column types are correct.
Column Recommended Power BI type
dateDate
trackerText
timezoneText
pageviewsWhole number
visitsWhole number

6. Build a first report

A simple report confirms that the imported fields behave correctly:

  1. Return to the Report view.
  2. Add a Line chart.
  3. Place date on the X-axis.
  4. Place pageviews and visits on the Y-axis.
  5. Add two Card visuals for the sums of pageviews and visits.
  6. Optionally add tracker as a slicer when the model later contains multiple trackers.

Select Home → Refresh to test the complete Desktop refresh. Existing visuals update when the query finishes.

7. Publish to Power BI Service

  1. Save the PBIX file in a protected location.
  2. In Power BI Desktop, select Home → Publish.
  3. Sign in with your organization's Power BI account.
  4. Select the intended workspace.
  5. Open the published report from the confirmation dialog.
Do not publish the report to a public web link. Publishing places the query and imported data in your organization's Power BI environment. Workspace members and semantic model owners must be trusted to handle this data and its API access.

Publishing creates a report and an associated semantic model. Scheduled refresh is configured on the semantic model, not on an individual chart or report page.

8. Configure scheduled refresh

  1. Open the workspace in Power BI Service.
  2. Find the semantic model created by the published PBIX file.
  3. Open Settings or select Refresh → Schedule refresh.
  4. Under Data source credentials, edit the credentials for https://api.nowmetrix.com.
  5. Select Anonymous as the authentication method and the privacy level required by your organization.
  6. Enable the refresh schedule and select an appropriate frequency and time zone.
  7. Enable refresh failure notifications for the semantic model owner or another responsible person.
  8. Save the settings, select Refresh now, and inspect Refresh history.
NowMetrix is a public HTTPS cloud source. A local data gateway is normally not required when Power BI Service can reach api.nowmetrix.com. The query deliberately uses RelativePath and Query, which are supported exceptions for refreshable web queries with variable query parameters.
If Power BI tests only the API base URL and offers Skip test connection, enable that option. The base URL alone is not a complete NowMetrix API request. If your organization disables hand-authored web queries or external cloud sources, ask the Power BI administrator to review the semantic model settings.

Available refresh frequencies depend on the Power BI license and workspace capacity. Microsoft documents the current controls, limits, failure behavior, and refresh history in its scheduled refresh guide.

Optional: make the key and tracker configurable

Power Query parameters make it easier to change the tracker or rotate the key without editing the entire query. They improve maintainability, but they are not a secret store.

  1. In Power Query Editor, select Home → Manage Parameters → New Parameter.
  2. Create a required Text parameter named pNowMetrixApiKey and enter the API key as its current value.
  3. Create another required Text parameter named pNowMetrixTrackerId and enter the tracker ID.
  4. Replace the first two query lines with the lines below.
    ApiKey = pNowMetrixApiKey,
    TrackerId = pNowMetrixTrackerId,

After publishing, editable parameters may appear in the semantic model settings. Workspace access must still be restricted because users with sufficient permissions can inspect or change them.

Add other NowMetrix datasets

Create a separate Power Query for each dataset and use relationships in the model when appropriate:

Use case Endpoint Modeling note
Daily Pageviews and Visits /v1/overview One row per tracker and date
Completed-period top pages /v1/recap Store the requested range with each imported result
Current live articles /v1/realtime A refresh replaces the snapshot unless you build separate history storage
Current sources /v1/sources Use the response timestamp when combining snapshots
Proofreading issues /v1/proofreading Restrict report access to the relevant editorial team
Each endpoint returns a different JSON structure. Copying the example and changing only RelativePath will not transform the new response correctly. Adapt the steps after Response using the endpoint's documented response example.

Security and sharing checklist

  • Use a dedicated NowMetrix API key for each Power BI semantic model.
  • Grant the NowMetrix user only the tracker access required by the report.
  • Store the PBIX file in a protected location and never publish it as a public download.
  • Treat PBIX editors and semantic model owners as trusted users who may inspect the query.
  • Do not place the key in visuals, report filters, URLs, screenshots, or documentation.
  • Use the smallest Power BI workspace audience that meets the reporting requirement.
  • Review report, workspace, app, build, reshare, and download permissions before distribution.
  • Revoke the key immediately if the PBIX file, workspace, or owner account may be compromised.
  • When ownership changes, confirm that refresh credentials and failure notifications still work.
Power Query parameters are configuration values, not secrets. Whether the key is written directly in the query or supplied through a parameter, access to the PBIX file and semantic model must remain restricted.

Troubleshooting

Problem What to check
Power BI keeps asking for credentials In File → Options and settings → Data source settings, clear permissions for https://api.nowmetrix.com, reconnect, and choose Anonymous.
401 or “access to the resource is forbidden” Check that the complete key replaced nm_YOUR_KEY, contains no spaces, and has not been revoked.
403 The key cannot access the configured tracker. Verify TRACKER_ID and the NowMetrix user's tracker permissions.
429 The tracker-wide API limit was exceeded. Wait and reduce scheduled or manual refresh frequency.
503 The analytics backend is temporarily unavailable. Keep the existing semantic model and retry later.
Desktop refresh works, Service refresh fails Check the semantic model's data source credentials, owner, privacy level, refresh history, and whether your administrator blocks cloud web sources or hand-authored queries.
Power BI reports a dynamic data source Confirm that the query still uses the fixed https://api.nowmetrix.com base URL with RelativePath and Query. Do not build the complete URL by concatenating text.
The scheduled refresh is disabled Open refresh history, resolve the latest failure, verify credentials, and enable the schedule again. Power BI can pause schedules after repeated failures or inactivity.
Gateway configuration appears unexpectedly Confirm that Power BI classifies the source as a reachable cloud Web source. Ask the workspace administrator to review gateway and cloud connection settings.