Case 6: HR report with a role
Finally the HR report goes to the division heads. Each should see only their departments, the report shows the part-time rate, and the title names the division and the number of employees.
In short: a role filters a table for everyone in it, here [Division] = "Operations" on the Department table. The part-time rate is DIVIDE(CALCULATE(COUNTROWS(Employee), Employee[EmploymentType] = "Part-time"), COUNTROWS(Employee)), the title "HR report " & SELECTEDVALUE(Department[Division], "all divisions") & ", " & COUNTROWS(Employee) & " employees".
The situation
The report is published to the Power BI service. The head of operations is responsible for Production and Logistics and must not see employee data from Sales and Administration. Instead of maintaining a separate file per division, the report gets roles.
Task 1: the role for operations
Task HR data is confidential. The head of operations should only see their departments in the published HR report. Write the table filter DAX expression of the role for the Department table: only departments in the Operations division.
Employee 46 rows, 8 columns
| EmployeeID | Name | DepartmentID | HireDate | LeaveDate | Salary | EmploymentType | Status |
|---|---|---|---|---|---|---|---|
| 101 | Sophie Lang | 1 | 1 Oct 2020 | 51500 | Full-time | Active | |
| 102 | Noah Walker | 1 | 1 Nov 2025 | 29600 | Part-time | Active | |
| 103 | Sophie Hayes | 1 | 1 Sep 2026 | 54100 | Full-time | Active | |
| 104 | Sam Price | 1 | 1 Aug 2024 | 60300 | Full-time | Active | |
| 105 | Ben Price | 1 | 1 Mar 2018 | 31 May 2026 | 66600 | Full-time | Left |
| 106 | Olivia Hughes | 1 | 1 Apr 2020 | 66000 | Full-time | Active | |
| 107 | Ben Bennett | 2 | 1 Nov 2012 | 44000 | Part-time | Active | |
| 108 | Jack Hughes | 2 | 1 Feb 2016 | 47600 | Full-time | Active | |
| 109 | Ben Hayes | 2 | 1 Apr 2021 | 31 Aug 2025 | 51000 | Full-time | Left |
| 110 | Lucy Clarke | 2 | 1 Oct 2019 | 57700 | Full-time | Active | |
| 111 | Ravi Ali | 2 | 1 Jul 2022 | 31 Mar 2025 | 48700 | Full-time | Left |
| 112 | Ben Foster | 2 | 1 Mar 2019 | 52100 | Full-time | Active |
Showing the first 12 of 46 rows.
Department 6 rows, 3 columns
| DepartmentID | Department | Division |
|---|---|---|
| 1 | Administration | Administration |
| 2 | Sales | Sales |
| 3 | Production | Operations |
| 4 | Logistics | Operations |
| 5 | IT | Administration |
| 6 | Customer Service | Sales |
Absence 486 rows, 5 columns
| AbsenceID | Date | EmployeeID | Type | Days |
|---|---|---|---|---|
| 1 | 1 Jan 2025 | 111 | Sick leave | 2 |
| 2 | 2 Jan 2025 | 101 | Vacation | 9 |
| 3 | 3 Jan 2025 | 127 | Sick leave | 4 |
| 4 | 3 Jan 2025 | 127 | Sick leave | 10 |
| 5 | 4 Jan 2025 | 142 | Sick leave | 2 |
| 6 | 6 Jan 2025 | 104 | Sick leave | 4 |
| 7 | 6 Jan 2025 | 118 | Vacation | 3 |
| 8 | 7 Jan 2025 | 124 | Sick leave | 4 |
| 9 | 7 Jan 2025 | 134 | Vacation | 6 |
| 10 | 12 Jan 2025 | 113 | Vacation | 7 |
| 11 | 15 Jan 2025 | 115 | Sick leave | 4 |
| 12 | 16 Jan 2025 | 117 | Sick leave | 2 |
Showing the first 12 of 486 rows.
Measures: [Absence Days]
Date 730 rows, 4 columns
| Date | Year | Month | MonthName |
|---|---|---|---|
| 1 Jan 2025 | 2025 | 1 | Jan |
| 2 Jan 2025 | 2025 | 1 | Jan |
| 3 Jan 2025 | 2025 | 1 | Jan |
| 4 Jan 2025 | 2025 | 1 | Jan |
| 5 Jan 2025 | 2025 | 1 | Jan |
| 6 Jan 2025 | 2025 | 1 | Jan |
| 7 Jan 2025 | 2025 | 1 | Jan |
| 8 Jan 2025 | 2025 | 1 | Jan |
| 9 Jan 2025 | 2025 | 1 | Jan |
| 10 Jan 2025 | 2025 | 1 | Jan |
| 11 Jan 2025 | 2025 | 1 | Jan |
| 12 Jan 2025 | 2025 | 1 | Jan |
Showing the first 12 of 730 rows.
In Power BI Desktop you create the role under Modeling, Manage roles, and test it with View as. The lesson on publishing and sharing explains how roles are assigned to people in the service and who they apply to.
Task 2: the part-time rate
Task Create the measure "Part-time Rate": the number of people with employment type Part-time divided by the number of all people, using DIVIDE. The matrix is filtered to active people.
Employee 46 rows, 8 columns
| EmployeeID | Name | DepartmentID | HireDate | LeaveDate | Salary | EmploymentType | Status |
|---|---|---|---|---|---|---|---|
| 101 | Sophie Lang | 1 | 1 Oct 2020 | 51500 | Full-time | Active | |
| 102 | Noah Walker | 1 | 1 Nov 2025 | 29600 | Part-time | Active | |
| 103 | Sophie Hayes | 1 | 1 Sep 2026 | 54100 | Full-time | Active | |
| 104 | Sam Price | 1 | 1 Aug 2024 | 60300 | Full-time | Active | |
| 105 | Ben Price | 1 | 1 Mar 2018 | 31 May 2026 | 66600 | Full-time | Left |
| 106 | Olivia Hughes | 1 | 1 Apr 2020 | 66000 | Full-time | Active | |
| 107 | Ben Bennett | 2 | 1 Nov 2012 | 44000 | Part-time | Active | |
| 108 | Jack Hughes | 2 | 1 Feb 2016 | 47600 | Full-time | Active | |
| 109 | Ben Hayes | 2 | 1 Apr 2021 | 31 Aug 2025 | 51000 | Full-time | Left |
| 110 | Lucy Clarke | 2 | 1 Oct 2019 | 57700 | Full-time | Active | |
| 111 | Ravi Ali | 2 | 1 Jul 2022 | 31 Mar 2025 | 48700 | Full-time | Left |
| 112 | Ben Foster | 2 | 1 Mar 2019 | 52100 | Full-time | Active |
Showing the first 12 of 46 rows.
Department 6 rows, 3 columns
| DepartmentID | Department | Division |
|---|---|---|
| 1 | Administration | Administration |
| 2 | Sales | Sales |
| 3 | Production | Operations |
| 4 | Logistics | Operations |
| 5 | IT | Administration |
| 6 | Customer Service | Sales |
Absence 486 rows, 5 columns
| AbsenceID | Date | EmployeeID | Type | Days |
|---|---|---|---|---|
| 1 | 1 Jan 2025 | 111 | Sick leave | 2 |
| 2 | 2 Jan 2025 | 101 | Vacation | 9 |
| 3 | 3 Jan 2025 | 127 | Sick leave | 4 |
| 4 | 3 Jan 2025 | 127 | Sick leave | 10 |
| 5 | 4 Jan 2025 | 142 | Sick leave | 2 |
| 6 | 6 Jan 2025 | 104 | Sick leave | 4 |
| 7 | 6 Jan 2025 | 118 | Vacation | 3 |
| 8 | 7 Jan 2025 | 124 | Sick leave | 4 |
| 9 | 7 Jan 2025 | 134 | Vacation | 6 |
| 10 | 12 Jan 2025 | 113 | Vacation | 7 |
| 11 | 15 Jan 2025 | 115 | Sick leave | 4 |
| 12 | 16 Jan 2025 | 117 | Sick leave | 2 |
Showing the first 12 of 486 rows.
Measures: [Absence Days]
Date 730 rows, 4 columns
| Date | Year | Month | MonthName |
|---|---|---|---|
| 1 Jan 2025 | 2025 | 1 | Jan |
| 2 Jan 2025 | 2025 | 1 | Jan |
| 3 Jan 2025 | 2025 | 1 | Jan |
| 4 Jan 2025 | 2025 | 1 | Jan |
| 5 Jan 2025 | 2025 | 1 | Jan |
| 6 Jan 2025 | 2025 | 1 | Jan |
| 7 Jan 2025 | 2025 | 1 | Jan |
| 8 Jan 2025 | 2025 | 1 | Jan |
| 9 Jan 2025 | 2025 | 1 | Jan |
| 10 Jan 2025 | 2025 | 1 | Jan |
| 11 Jan 2025 | 2025 | 1 | Jan |
| 12 Jan 2025 | 2025 | 1 | Jan |
Showing the first 12 of 730 rows.
This exercise is part of Premium.
Premium unlocks every exercise in every lesson, unlimited practice with fresh tasks and the final test with certificate.
See Premium Already Premium? Log in
The first exercise in this lesson is free.
CALCULATE counts the rows with the extra Part-time filter, the denominator counts all rows in the current filter. More in the lesson on CALCULATE. Nobody in Customer Service works part-time; the rate is blank there, because CALCULATE returns blank and DIVIDE with a blank numerator returns blank. The matrix hides rows in which every value is blank, so Customer Service does not appear.
Task 3: the title
Task The title of the HR report should name the division and the number of employees. Create the measure "Report Title": "HR report ", then the division ("all divisions" when none or several are selected), a comma and a space, the number of people and " employees". As in task 2, the matrix is filtered to active people.
Employee 46 rows, 8 columns
| EmployeeID | Name | DepartmentID | HireDate | LeaveDate | Salary | EmploymentType | Status |
|---|---|---|---|---|---|---|---|
| 101 | Sophie Lang | 1 | 1 Oct 2020 | 51500 | Full-time | Active | |
| 102 | Noah Walker | 1 | 1 Nov 2025 | 29600 | Part-time | Active | |
| 103 | Sophie Hayes | 1 | 1 Sep 2026 | 54100 | Full-time | Active | |
| 104 | Sam Price | 1 | 1 Aug 2024 | 60300 | Full-time | Active | |
| 105 | Ben Price | 1 | 1 Mar 2018 | 31 May 2026 | 66600 | Full-time | Left |
| 106 | Olivia Hughes | 1 | 1 Apr 2020 | 66000 | Full-time | Active | |
| 107 | Ben Bennett | 2 | 1 Nov 2012 | 44000 | Part-time | Active | |
| 108 | Jack Hughes | 2 | 1 Feb 2016 | 47600 | Full-time | Active | |
| 109 | Ben Hayes | 2 | 1 Apr 2021 | 31 Aug 2025 | 51000 | Full-time | Left |
| 110 | Lucy Clarke | 2 | 1 Oct 2019 | 57700 | Full-time | Active | |
| 111 | Ravi Ali | 2 | 1 Jul 2022 | 31 Mar 2025 | 48700 | Full-time | Left |
| 112 | Ben Foster | 2 | 1 Mar 2019 | 52100 | Full-time | Active |
Showing the first 12 of 46 rows.
Department 6 rows, 3 columns
| DepartmentID | Department | Division |
|---|---|---|
| 1 | Administration | Administration |
| 2 | Sales | Sales |
| 3 | Production | Operations |
| 4 | Logistics | Operations |
| 5 | IT | Administration |
| 6 | Customer Service | Sales |
Absence 486 rows, 5 columns
| AbsenceID | Date | EmployeeID | Type | Days |
|---|---|---|---|---|
| 1 | 1 Jan 2025 | 111 | Sick leave | 2 |
| 2 | 2 Jan 2025 | 101 | Vacation | 9 |
| 3 | 3 Jan 2025 | 127 | Sick leave | 4 |
| 4 | 3 Jan 2025 | 127 | Sick leave | 10 |
| 5 | 4 Jan 2025 | 142 | Sick leave | 2 |
| 6 | 6 Jan 2025 | 104 | Sick leave | 4 |
| 7 | 6 Jan 2025 | 118 | Vacation | 3 |
| 8 | 7 Jan 2025 | 124 | Sick leave | 4 |
| 9 | 7 Jan 2025 | 134 | Vacation | 6 |
| 10 | 12 Jan 2025 | 113 | Vacation | 7 |
| 11 | 15 Jan 2025 | 115 | Sick leave | 4 |
| 12 | 16 Jan 2025 | 117 | Sick leave | 2 |
Showing the first 12 of 486 rows.
Measures: [Absence Days]
Date 730 rows, 4 columns
| Date | Year | Month | MonthName |
|---|---|---|---|
| 1 Jan 2025 | 2025 | 1 | Jan |
| 2 Jan 2025 | 2025 | 1 | Jan |
| 3 Jan 2025 | 2025 | 1 | Jan |
| 4 Jan 2025 | 2025 | 1 | Jan |
| 5 Jan 2025 | 2025 | 1 | Jan |
| 6 Jan 2025 | 2025 | 1 | Jan |
| 7 Jan 2025 | 2025 | 1 | Jan |
| 8 Jan 2025 | 2025 | 1 | Jan |
| 9 Jan 2025 | 2025 | 1 | Jan |
| 10 Jan 2025 | 2025 | 1 | Jan |
| 11 Jan 2025 | 2025 | 1 | Jan |
| 12 Jan 2025 | 2025 | 1 | Jan |
Showing the first 12 of 730 rows.
This exercise is part of Premium.
Premium unlocks every exercise in every lesson, unlimited practice with fresh tasks and the final test with certificate.
See Premium Already Premium? Log in
The first exercise in this lesson is free.
SELECTEDVALUE returns the division when exactly one is in the filter, otherwise the alternate value. COUNTROWS counts the people in the filter of each row, and & turns the number into text. With the role from task 1 the head of operations only ever sees one division, and the title reads "HR report Operations, 17 employees". The lesson on building a dashboard shows how to use a measure as a title.
Common mistakes
Role on the wrong table
The rule [Division] = "Operations" belongs to the Department table, because only that table has the Division column. On Employee or Absence it is an error.
Rate with a fixed total
Dividing by 37 instead of COUNTROWS(Employee) gives the right rate only in the total row. Every department needs its own denominator.
Text joined without a space
"HR report" & division gives "HR reportOperations". The space belongs in the text: "HR report ".
In real Power BI
- Row-level security applies to people with the Viewer role in the workspace. Anyone who administers or edits the workspace sees all data. For HR data, decide carefully who gets which workspace role.
- Instead of one role per division, a table with email address and division can hold the mapping; the rule then checks
USERPRINCIPALNAME(). That pays off as soon as responsibilities change often.
Check your result
- Task 1: With the role the 2026 matrix shows 297 absence days for Full-time and 207 for Part-time.
- Task 2: IT has the highest part-time rate with 60%, Logistics 40%, and the total is 27.0%. Customer Service is missing because its rate is blank.
- Task 3: The rows read "HR report Operations, 17 employees", "HR report Administration, 10 employees" and "HR report Sales, 10 employees", the total row "HR report all divisions, 37 employees".
Back to case 5 or the course overview.