# Load job postings data into Power BI

> Load job posts into Power BI with a Power Query (M) script that pages through results and refreshes in the Power BI service.

Page: https://jobdataapi.com/integrations/power-bi/
Category: Spreadsheets and no-code
You need: Power BI Desktop; the same query also works in Excel's Power Query and a jobdata API key (https://jobdataapi.com/accounts/pricing/).

## Steps

1. In Power BI Desktop choose Get data &rarr; Blank query &rarr; Advanced editor and paste the script.
2. Set your API key and filters in the Query record.
3. Use Anonymous credentials for the data source - the API key travels in the header.
4. Publish and set a scheduled refresh; the static base URL keeps the query refreshable in the service.

## Code

```powerquery
let
    ApiKey = "YOUR_API_KEY",
    GetPage = (page as number) => Json.Document(Web.Contents("https://jobdataapi.com", [
        RelativePath = "api/jobs/",
        Query = [title = "analyst", max_age = "30", page_size = "1000", page = Text.From(page)],
        Headers = [Authorization = "Api-Key " & ApiKey]
    ])),
    Pages = List.Generate(
        () => [n = 1, r = GetPage(1)],
        each [r] <> null,
        each [n = [n] + 1, r = if [r][next] = null then null else GetPage([n] + 1)],
        each [r][results]
    ),
    Jobs = Table.FromRecords(
        List.Combine(Pages),
        {"id", "title", "location", "published", "has_remote", "application_url"},
        MissingField.UseNull
    )
in
    Jobs
```

## Notes

- Expand the nested company record with Expand column if you need company name, website or logo.
- Keep the base URL static and pass filters via Query - dynamic URLs block scheduled refresh in the Power BI service.

## Related docs

- [Integrating the jobdata API with Excel](https://jobdataapi.com/c/integrating-the-jobdata-api-with-excel/)
- [Jobs API Ingestion Guide: Reliable Historical Backfills and Incremental Syncs](https://jobdataapi.com/c/jobs-api-ingestion-guide-reliable-historical-backfills-and-incremental-syncs/)

