Power BI — NHS Quickstart
When your Trust uses SQL Server and needs governed, interactive reports for managers or clinics, Power BI is often the fastest path. This guide focuses on safe patterns (parameterised SQL, RLS, Gateway) so you can publish quickly and securely.
⚙️ 10‑minute setup
- Install Power BI Desktop (current version).
- Ensure you have read access to your reporting database (or a dev/schema).
- Confirm ODBC Driver 18 for SQL Server (for encrypted connections) is installed.
🚀 “Hello NHS” report (SQL Server → visual)
1) Create a parameter for your server/database
In Power Query → Manage Parameters:
pServer=YOURSERVERpDatabase=NHS_Analytics
2) Create a safe, foldable query
Power Query (Advanced Editor) — parameterised and encrypted connection:
let
Source = Sql.Database(pServer, pDatabase, [CreateNavigationProperties=false, Encrypt=true]),
Query = Value.NativeQuery(
Source,
"SELECT practice_id, start_time, attended
FROM dbo.appointments
WHERE start_time >= DATEADD(DAY, -30, SYSUTCDATETIME());",
null, [EnableFolding=true])
in
Query
Tip: Use
Value.NativeQueryonly when you need custom SQL; otherwise build queries with the GUI to preserve folding.
3) Add basic measures (DAX)
Total Appointments := COUNTROWS('appointments')
Attendance Rate :=
DIVIDE(
CALCULATE(COUNTROWS('appointments'), 'appointments'[attended] = TRUE() ),
[Total Appointments]
)
Median Wait (mins) :=
MEDIANX(
'appointments',
DATEDIFF('appointments'[start_time], 'appointments'[start_time], MINUTE)
)
Keep measures in a Measures table for clarity (Home → Enter Data → name it Measures, store measures there).
4) Visualise
- Add a bar chart with practice_id on Axis and Total Appointments as Value.
- Add a card for Attendance Rate.
- Save as
NHS_KPI.pbix.
🔐 Row‑Level Security (RLS)
- Model view → Manage roles.
- Add role
PracticeViewerwith filter on table that holds practice visibility, e.g.:
Practice[practice_id] = USERPRINCIPALNAME()(or match on a mapping table). - View as → test the role in Desktop.
- After publishing, assign users or AAD groups to the role in the Service workspace.
Prefer AAD groups over individuals; document role logic in the repo README.
☁️ Publish + Gateway + Refresh
- Publish (Service)
- On‑premises Gateway
- Scheduled refresh
- Home → Publish to a Workspace (not My workspace).
- Open the dataset in the Service → Settings.
- Configure Credentials (OAuth/Windows as per Trust policy).
If SQL Server is on‑prem:
- Install On‑premises Data Gateway (Standard) on a Windows VM/server that can reach SQL.
- Sign in with a Service/Work account → register a Gateway and Data Source (server, DB, auth).
- In the dataset Settings → Gateway connections → map your data source.
- In Dataset → Settings → Scheduled refresh, enable up to 8/day (more with Premium).
- Consider Incremental refresh to reduce load (see below).
- Monitor failures with Subscriptions or Activity log.
⚡ Performance & modelling tips
- Import mode for small/medium tables; DirectQuery when live, but watch latency.
- Use a star schema (Fact Appointments → Dim Practice/Date).
- Create a proper Date table and mark it as Date table.
- Push heavy filters/calcs to SQL (folding) or pre‑aggregate with a view.
- For large facts: use Aggregations or Incremental Refresh.
Incremental Refresh (example policy):
- Parameterise
RangeStart/RangeEndin Power Query. - Filter
start_timewith>= RangeStart and < RangeEnd. - In Desktop: Table → Incremental refresh → Store data for 24 months, refresh last 3 days.
🧰 NHS‑ready add‑ons
- Shared datasets: centralise conformed models, build thin reports on top.
- Dataflows Gen2: move repeated Power Query logic out of Desktop.
- Deployment Pipelines: Dev → Test → Prod with rules for connections/parameters.
- Power BI Projects (.pbip): store model/report as text files for Git versioning.
- RLS + “View as” embedded in training packs for analysts.
🛡 IG & safety checklist
- Encrypt connections (
Encrypt=true/ ODBC Driver 18). - Filter at source; exclude free‑text PHI; apply small‑number suppression.
- Secure with RLS + AAD groups; avoid sharing to Everyone.
- Keep credentials in the Gateway or Service data source — not in queries.
- Document data sources, owners, refresh cadence, and KPI definitions.
📏 Measuring impact
- Refresh latency (source load → dashboard updated).
- Reliability (% successful refreshes).
- Adoption (report views, active users).
- Model quality (validation checks vs source, measure review sign‑off).
🔗 See also
What’s next?
You’ve completed the Learn — Power BI stage. Keep momentum: