Connect Power BI
This guide is for the person who builds reports in Power BI. It takes about 15 minutes. You need Power BI Desktop, a Salma Console login, and the Data API add-on switched on for your Organisation.
Salma gives Power BI one table per form, one per repeat group, and one per list. Each table has one plain value per column and the same columns on every row, so Power BI can load it without extra steps.
What you need
Section titled “What you need”- Power BI Desktop. It runs on Windows 10 or later only. On a Mac, use a Windows virtual machine or a Windows cloud PC. Source: https://learn.microsoft.com/en-us/power-bi/fundamentals/desktop-get-the-desktop
- A Power BI account to publish and schedule refreshes. It needs a work or school email; Gmail or Hotmail addresses are not accepted. Source: https://learn.microsoft.com/en-us/power-bi/fundamentals/service-self-service-signup-for-power-bi
- A Salma API key. In the Console, open your profile and go to API keys. Enter a name, for example
Power BI field report, and click Create API key. Copy the key now; Salma shows it once. - Your Salma data address. It is shown next to your API keys. It ends in
/data.
Part 1. Find your table names
Section titled “Part 1. Find your table names”In Power BI Desktop: Home, Get data, Blank query, Advanced Editor, and paste this, with your data address:
let SalmaBase = "https://YOUR-SALMA-ADDRESS/data", Tables = Json.Document(Web.Contents(SalmaBase, [RelativePath = "v1/tables"]))in TablesWhen Power BI asks how to connect, choose Basic: user name key, password your API key, at the level of the data address. The reply lists every table you can read:
| Table name | One row per |
|---|---|
form_<form key> |
submission |
form_<form key>__<repeat key> |
answer set in a repeat group, with submission_id to join back to the form table |
lookup_<list key> |
record in a list, for example a farmer |
Part 2. Load a table in Power BI Desktop
Section titled “Part 2. Load a table in Power BI Desktop”- Home, Get data, Blank query. Then Advanced Editor.
- Paste the query from power-bi-salma-table.pq (download it, open it in a text editor and copy it).
- Change
SalmaBaseto your data address andTableNameto a name from Part 1. Click Done. - When Power BI asks how to connect, choose Basic. User name
key, password your API key. Set the level to the data address, not the full table address, so one sign-in covers every table. - Name the query after the form, then Close and Apply.
Repeat for each table. Power BI loads text and numbers as plain values; set each column’s type (Whole number, Decimal, Date) in Power Query once.
What the columns mean
Section titled “What the columns mean”| Column | Meaning |
|---|---|
submission_id |
The submission. Joins a repeat table to its form table. |
review_status |
received (not reviewed yet), hasIssues, approved or rejected. Rejected submissions are left out. |
salma_officer_id, salma_officer_name |
The field officer who sent it. |
received_at |
When Salma received it. |
salma_released_at |
When it became available to reports. |
salma_form_version |
The form version the officer used. |
<question> |
The answer. For a multiple choice question, the chosen values separated by spaces. |
<question>_label |
The labels of the chosen options. |
<question>_latitude, _longitude, _altitude, _accuracy |
A GPS point, ready for a map visual. |
<question>_mode |
For a list question: how the officer picked the record. |
salma_row_seq, salma_modified_at |
When the row last changed in Salma. |
Form columns never disappear. If a later form version drops a question, its column stays and new rows leave it empty. A new question adds a column. A table with no rows yet (or none left, after the last one is deleted or rejected) comes back with no columns, so load a table after its first visit. List tables are different: a list field’s column disappears if that field is blank on every record, so a report step that names it can fail on refresh.
Part 3. Publish and refresh
Section titled “Part 3. Publish and refresh”- Publish from Power BI Desktop to your workspace.
- In the Power BI service, open the semantic model’s settings. Under Data source credentials, sign in with Basic again (
keyand your API key). - Under Refresh, turn on scheduled refresh. Power BI allows up to eight refreshes a day on shared capacity. Source: https://learn.microsoft.com/en-us/power-bi/connect-data/refresh-data
Each refresh reads every row again, so deleted and corrected submissions are always right. No gateway is needed: Salma is on the internet.
Troubleshooting
Section titled “Troubleshooting”| What you see | What to do |
|---|---|
| 401 or a sign-in prompt again | The key was revoked or mistyped. Make a new key and edit the credentials. |
| 403 feature disabled | The Data API add-on is off for your Organisation. Ask Salma support. |
| 404 | The table name is wrong, or the form is confidential. Check Part 1. |
| 429 | Too many requests at once. Refresh fewer tables at the same time, or wait a minute. |
| “This dataset includes a dynamic data source” | The query was changed to build the address by hand. Use the query from this guide unchanged apart from the two values. |