# HR turnover for managers without exposing anyone

Turnover is leavers in a period divided by average headcount, published as rates for groups above a minimum size. Hiding one small group is not enough: counts and totals let a reader subtract it back. Merge small groups into one larger row, publish rates without counts, and say that your thresholds are your own choice, not a legal rule.

- Checked on 2026-11-29
- Rodrigo Lombana Reina, https://thefabricofdata.com/profile/
- https://thefabricofdata.com/patterns/hr-turnover-without-exposing-anyone/

## The problem
A manager asks for turnover by team. Some teams have four people, and a single leaver is easy to name. Hide that team's rate and you may still publish enough around it for a reader to work it out. This Pattern is for HR analysts and BI developers who must show turnover at group level and keep individuals out of the report. All data here is synthetic, and none of it is legal advice.

## Steps
![Top lane: the rate of a small group is hidden but counts stay visible, so company leavers minus visible groups gives the hidden count. Bottom lane: small groups are merged into one Other row and only rates are published.](https://thefabricofdata.com/_astro/12-leak-and-merge.CTSXg1Tc.svg)

*Hiding one number leaks it by subtraction. Merging small groups and publishing rates only does not.*

Two things first. The table in the project has 382 made-up employee codes, a department and two month numbers, nothing else. And the thresholds below, fewer than 10 people on average and fewer than 5 leavers, are the author's own choice for this example. They are not a legal rule.

1. **Agree purpose and rules before you build anything.** Write down why the report exists, which legal basis applies and who may see what. The GDPR asks that personal data be "collected for specified, explicit and legitimate purposes" (Article 5(1)(b)), and lists the possible bases for processing in Article 6(1). Which one fits your report is a question for your data protection officer or lawyer. This Pattern does not answer it.

2. **Keep identifiers out of the model.** Use a made-up code, a department and two month numbers. Leave out names, birth dates, salary, health and free-text exit reasons. Data is to be "adequate, relevant and limited to what is necessary" (Article 5(1)(c)), and health data and trade union membership are special categories with a general prohibition in Article 9(1). A code instead of a name does not make the data anonymous: Article 4(5) defines pseudonymisation, and Recital 26 says pseudonymised data that could be attributed to a person with additional information "should be considered to be information on an identifiable natural person".

3. **Calculate the rate.** A person is employed at the end of month `m` when `start_m <= m` and `end_m` is empty or greater than `m`; `end_m` is the month the person left. Turnover is leavers in the period divided by the average of the headcount at the start and at the end. `$p_start` and `$p_end` are the first and last month.

   ```sql
   -- Raw counts per department for one period (month numbers, both ends included).
   -- A person counts as employed at the end of month m when start_m <= m and (end_m is empty or end_m > m).
   -- end_m is the month the person left.
   -- $p_start and $p_end are the first and last month of the period.
   SELECT
       dept,
       count(*) FILTER (WHERE start_m <= $p_start - 1 AND (end_m IS NULL OR end_m > $p_start - 1)) AS hc_start,
       count(*) FILTER (WHERE start_m <= $p_end       AND (end_m IS NULL OR end_m > $p_end))       AS hc_end,
       count(*) FILTER (WHERE end_m BETWEEN $p_start AND $p_end)                                   AS leavers
   FROM employees
   GROUP BY dept
   ORDER BY dept;
   ```

   For months 25 to 36 the synthetic company had 54 leavers on an average headcount of 222.0: 24.3%. This table is for the analyst, not for publication.

4. **Hide the small groups.** The first idea is to hide the rate when a group is small. The query below keeps counts visible, to show what goes wrong in the next step.

   ```sql
   -- The first idea: hide the rate of small groups. Counts stay visible.
   -- The thresholds (10 people on average, 5 leavers) are this project's own choice, not a legal rule.
   WITH hc AS (
       SELECT
           dept,
           count(*) FILTER (WHERE start_m <= $p_start - 1 AND (end_m IS NULL OR end_m > $p_start - 1)) AS hc_start,
           count(*) FILTER (WHERE start_m <= $p_end       AND (end_m IS NULL OR end_m > $p_end))       AS hc_end,
           count(*) FILTER (WHERE end_m BETWEEN $p_start AND $p_end)                                   AS leavers
       FROM employees
       GROUP BY dept
   )
   SELECT
       dept, hc_start, hc_end, leavers,
       round((hc_start + hc_end) / 2.0, 1) AS avg_hc,
       CASE
           WHEN (hc_start + hc_end) / 2.0 < 10 THEN 'suppressed (fewer than 10 people)'
           WHEN leavers < 5                    THEN 'suppressed (fewer than 5 leavers)'
           ELSE CAST(round(100.0 * leavers / ((hc_start + hc_end) / 2.0), 1) AS VARCHAR)
       END AS turnover_pct_published
   FROM hc
   ORDER BY dept;
   ```

   For reference, Microsoft's Viva Insights says aggregated insights "won't show results for groups with fewer than five people", and that an administrator must set the minimum group size to at least five. The Copilot Dashboard default is 10. Those are settings of one product. The GDPR text read for this Pattern contains no minimum group size.

5. **Check whether the hidden number comes back.** It does. Legal (7.0 people on average) has its rate hidden, but the leaver counts and the company total are visible. Company leavers (54) minus the visible groups (53) leaves 1, and with only one group hidden that one belongs to Legal.

   ```python
   def recoverable_from_counts(naive_rows: list[dict], company_leavers: int) -> dict:
       """What a reader learns by subtraction when leaver counts and the company total are visible.

       The leavers of hidden groups are not published, so the reader only has the
       company total and the counts of the visible groups. Returns the number of
       leavers that sit in the hidden groups and whether one group is pinned down exactly.
       """
       hidden = [g["dept"] for g in naive_rows if g["published_rate"] is None]
       visible_leavers = sum(g["leavers"] for g in naive_rows if g["published_rate"] is not None)
       return {"hidden_groups": hidden,
               "leavers_in_hidden_groups": company_leavers - visible_leavers,
               "exact_for_one_group": len(hidden) == 1}
   ```

   Microsoft's page makes the same point: with very small groups or overlapping groups, "they may still be able to identify a specific person from aggregated data". This is called differencing. The run recovered the figure exactly.

6. **Merge small groups and publish rates only.** Groups that fail either rule go into one row called `Other`. If `Other` is still too small, the smallest published group joins it. Counts are never returned. Here Legal and Finance became one row of 20.5 people on average.

   ```python
   def safe_view(rows, min_avg=MIN_AVG_HEADCOUNT, min_leavers=MIN_LEAVERS) -> list[dict]:
       """Publish rates only. Small groups are merged into 'Other', and 'Other' grows
       (smallest remaining group first) until it is no longer small itself.

       Returns rows with dept and published_rate (None when even the merge stays small).
       No leaver counts are returned.
       """
       big = sorted((g for g in rows if not is_small(g, min_avg, min_leavers)), key=lambda g: g["avg_hc"])
       small = [g for g in rows if is_small(g, min_avg, min_leavers)]
       other = None
       if small:
           other = combine(small, "Other")
           while is_small(other, min_avg, min_leavers) and big:
               other = combine([other, big.pop(0)], "Other")
       shown = [{"dept": g["dept"], "published_rate": round(rate(g), 1)}
                for g in sorted(big, key=lambda g: g["dept"])]
       if other:
           pub = None if is_small(other, min_avg, min_leavers) else round(rate(other), 1)
           shown.append({"dept": "Other", "published_rate": pub})
       return shown
   ```

   The run printed Engineering 14.5%, Operations 58.1%, Sales 15.7%, Support 43.6%, Other 29.3% and Company 24.3%. The cost is detail: Finance disappears as its own row, and `Other` mixes unrelated teams.

7. **Limit who sees which rows.** Apply row-level security to the published table, not to the employee table, so a manager sees only the rows meant for them. Fabric Data Warehouse implements it with `CREATE SECURITY POLICY` and a predicate function. Microsoft's page says it applies only to queries on a Warehouse or SQL analytics endpoint, and warns that carefully crafted queries that use errors can leak data.

   ```sql
   -- Adapted from Microsoft's row-level security example; names are placeholders.
   CREATE SCHEMA Security;
   GO

   CREATE FUNCTION Security.fn_manager_filter(@ManagerLogin AS nvarchar(128))
       RETURNS TABLE
   WITH SCHEMABINDING
   AS
       RETURN SELECT 1 AS fn_result
       WHERE @ManagerLogin = USER_NAME() OR USER_NAME() = '<hr-analyst-login>';
   GO

   CREATE SECURITY POLICY ManagerFilter
   ADD FILTER PREDICATE Security.fn_manager_filter(ManagerLogin)
   ON hr.TurnoverPublished
   WITH (STATE = ON);
   GO
   ```

8. **Document it.** Record the definition of turnover, the thresholds and who chose them, and who may see what. Article 35(1) requires a data protection impact assessment where processing "is likely to result in a high risk to the rights and freedoms of natural persons". Whether yours is one is a decision for your data protection officer.

## The project
`hr-turnover-safe` is a small Python and DuckDB project with synthetic data. It contains the generator, the two SQL files above, the suppression and subtraction code, a demo and 19 tests.

```bash
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python run.py && python -m pytest -v
```

What the recorded run showed (full output in `RUN_LOG.txt`, inside the project):

- Naive suppression hid only Legal. The subtraction returned 1 leaver for the hidden group, exactly.
- The safer view published five rows plus the company rate, and no counts.
- One leaver gives 25.0% in a team of 4, 12.5% in a team of 8 and 2.5% in a team of 40.
- 19 tests passed. They cover the boundaries of both thresholds (exactly 10 people, exactly 5 leavers), the case of two hidden groups, where only their sum leaks, and a check that the SQL and the Python give the same published rates.

![Terminal output of the demo and the test summary.](https://thefabricofdata.com/_astro/12-run-output.BmBt7UtQ.svg)

*Real output of `python run.py` (blocks 2 to 4) and the test summary, DuckDB 2.0.1, 2026-11-29. Synthetic data.*

## Copy this prompt

To try different privacy thresholds, paste this into your assistant’s chat with a synthetic table and enter the period and minimum group and leaver counts. Ask it to calculate turnover, show how small groups could be inferred and propose which groups to combine or suppress before publishing rates.

```text
Using ONLY this synthetic table (no real people):
emp(emp_id, dept, start_m, end_m). start_m and end_m are month numbers.
Compute turnover for months <first> to <last> by department:
leavers divided by the average of headcount at start and at end.
Then apply my thresholds: hide a department with average headcount under <N>
or fewer than <M> leavers. Treat these thresholds as my own choice, not a legal rule.
Explain how a reader could still recover a hidden figure from counts and totals,
and propose a version that publishes rates only and merges small groups.
Do not ask for or use names, salaries, health data or any real employee data.
```
Check the answer for three things: leavers divided by the average of start and end headcount, a way to stop subtraction, and no counts in the published output.

## Test result

With synthetic data, the DuckDB exercise recovered a hidden count by subtracting totals. Its second output combined small groups and showed the rates alone.

## Limits
- **This is not legal advice.** The GDPR is one layer. Member States may add "more specific rules" for employment (Article 88(1)), and Microsoft's own page warns that an analysis that is acceptable in one country may need more in another, or be illegal. Works councils and employee consultation vary by country. Ask your data protection officer.
- **The thresholds are a choice.** 10 people and 5 leavers are the author's own numbers. Viva's five and ten are product settings, not standards. The GDPR text sets no minimum group size.
- **The safer view stops this subtraction, not every leak.** Comparing several reports, a group that is large this year and small next year, overlapping groups, or what a manager already knows about their team can still reveal a person.
- **Tiny denominators swing the rate.** One leaver is 25.0% in a team of 4. Do not rank managers by it.
- **Merging costs detail.** `Other` mixes unrelated teams, and a small team never gets its own number.
- **A code is not anonymity.** Pseudonymised data stays personal data under Recital 26. Keep employee-level rows out of the model, the exports and every prompt.
- **Row-level security does not decide the thresholds.** It filters rows by user. The suppression has to happen before.
- **The period is 12 months.** The rate is annual for months 25 to 36. A three-month rate is not an annual one without saying so.
- **Article numbers can change.** They come from the 2016 Official Journal text. Check the current consolidated version before you quote them.

## Sources
- [General Data Protection Regulation, Regulation (EU) 2016/679, official text](https://eur-lex.europa.eu/eli/reg/2016/679/oj), accessed 2026-11-29
- [Viva Insights advanced analysis privacy](https://learn.microsoft.com/en-us/viva/insights/advanced/privacy/privacy), accessed 2026-11-29
- [Customize Viva Insights privacy settings](https://learn.microsoft.com/en-us/viva/insights/advanced/setup-maint/privacy-settings), accessed 2026-11-29
- [Manage settings for the Microsoft Copilot Dashboard and Viva Insights web app](https://learn.microsoft.com/en-us/viva/insights/advanced/admin/manage-settings-copilot-dashboard), accessed 2026-11-29
- [Row-level security in Fabric Data Warehouse](https://learn.microsoft.com/en-us/fabric/data-warehouse/row-level-security), accessed 2026-11-29

## Author
Rodrigo Lombana Reina, data engineer. Personal opinions. Checked against the documentation and the Regulation on 2026-11-29. Not legal advice.

## Questions

### How do you calculate the employee turnover rate by department?

Divide the leavers in the period by the average headcount, where the average is the headcount at the start plus the headcount at the end, divided by two. In the synthetic data of this Pattern, run in DuckDB 2.0.1, 54 leavers on an average headcount of 222.0 gave 24.3% for months 25 to 36. See step 3.

### How can I report turnover without identifying individuals?

Publish rates for groups above a minimum size, merge smaller groups into one row, and leave out leaver counts so nobody can subtract them. Keep names, salary and health data out of the model. In the DuckDB 2.0.1 run, hiding only Legal's rate let a reader recover its single leaver; merging Legal with Finance prevented it. Not legal advice.

### What is the minimum group size for HR reports?

There is no universal number. Microsoft Viva Insights will not show results for groups under five people and defaults to 10 in its Copilot Dashboard, but those are product settings. The GDPR text read for this Pattern sets no group size. This Pattern uses 10 people and 5 leavers as the author's own choice; decide yours with your data protection officer.

### Is pseudonymised employee data still personal data under the GDPR?

Yes. Recital 26 of Regulation (EU) 2016/679 says pseudonymised data that could be attributed to a person with additional information should be considered information on an identifiable natural person. Replacing names with employee codes does not make a table anonymous, so keep employee-level rows out of shared models and exports. This is not legal advice.

### What is the main mistake when hiding small teams in an HR report?

Hiding one number but leaving counts and totals visible. A reader subtracts the visible groups from the company total and gets the hidden group back. In the recorded run, 54 company leavers minus 53 in the visible groups returned Legal's single leaver. Publish rates without counts, and merge small groups so no single group is pinned down.

### Does row-level security in Fabric solve this problem?

No. Row-level security in Fabric Data Warehouse filters which rows each user can query, using CREATE SECURITY POLICY and a predicate function. It does not decide which groups are too small to show. Apply the suppression first, then secure the published table. Microsoft's page also warns about leaks through crafted queries. The T-SQL here was not executed.

### Do I need a data protection impact assessment for turnover reporting?

Article 35(1) of the GDPR requires one where processing is likely to result in a high risk to the rights and freedoms of people. Whether a turnover report reaches that level is a decision for your data protection officer, and national rules differ. Document your thresholds and access rules either way. This Pattern is not legal advice.
