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
EmployeeIDNameDepartmentIDHireDateLeaveDateSalaryEmploymentTypeStatus
101Sophie Lang11 Oct 202051500Full-timeActive
102Noah Walker11 Nov 202529600Part-timeActive
103Sophie Hayes11 Sep 202654100Full-timeActive
104Sam Price11 Aug 202460300Full-timeActive
105Ben Price11 Mar 201831 May 202666600Full-timeLeft
106Olivia Hughes11 Apr 202066000Full-timeActive
107Ben Bennett21 Nov 201244000Part-timeActive
108Jack Hughes21 Feb 201647600Full-timeActive
109Ben Hayes21 Apr 202131 Aug 202551000Full-timeLeft
110Lucy Clarke21 Oct 201957700Full-timeActive
111Ravi Ali21 Jul 202231 Mar 202548700Full-timeLeft
112Ben Foster21 Mar 201952100Full-timeActive

Showing the first 12 of 46 rows.

Department 6 rows, 3 columns
DepartmentIDDepartmentDivision
1AdministrationAdministration
2SalesSales
3ProductionOperations
4LogisticsOperations
5ITAdministration
6Customer ServiceSales
Absence 486 rows, 5 columns
AbsenceIDDateEmployeeIDTypeDays
11 Jan 2025111Sick leave2
22 Jan 2025101Vacation9
33 Jan 2025127Sick leave4
43 Jan 2025127Sick leave10
54 Jan 2025142Sick leave2
66 Jan 2025104Sick leave4
76 Jan 2025118Vacation3
87 Jan 2025124Sick leave4
97 Jan 2025134Vacation6
1012 Jan 2025113Vacation7
1115 Jan 2025115Sick leave4
1216 Jan 2025117Sick leave2

Showing the first 12 of 486 rows.

Measures: [Absence Days]

Date 730 rows, 4 columns
DateYearMonthMonthName
1 Jan 202520251Jan
2 Jan 202520251Jan
3 Jan 202520251Jan
4 Jan 202520251Jan
5 Jan 202520251Jan
6 Jan 202520251Jan
7 Jan 202520251Jan
8 Jan 202520251Jan
9 Jan 202520251Jan
10 Jan 202520251Jan
11 Jan 202520251Jan
12 Jan 202520251Jan

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
EmployeeIDNameDepartmentIDHireDateLeaveDateSalaryEmploymentTypeStatus
101Sophie Lang11 Oct 202051500Full-timeActive
102Noah Walker11 Nov 202529600Part-timeActive
103Sophie Hayes11 Sep 202654100Full-timeActive
104Sam Price11 Aug 202460300Full-timeActive
105Ben Price11 Mar 201831 May 202666600Full-timeLeft
106Olivia Hughes11 Apr 202066000Full-timeActive
107Ben Bennett21 Nov 201244000Part-timeActive
108Jack Hughes21 Feb 201647600Full-timeActive
109Ben Hayes21 Apr 202131 Aug 202551000Full-timeLeft
110Lucy Clarke21 Oct 201957700Full-timeActive
111Ravi Ali21 Jul 202231 Mar 202548700Full-timeLeft
112Ben Foster21 Mar 201952100Full-timeActive

Showing the first 12 of 46 rows.

Department 6 rows, 3 columns
DepartmentIDDepartmentDivision
1AdministrationAdministration
2SalesSales
3ProductionOperations
4LogisticsOperations
5ITAdministration
6Customer ServiceSales
Absence 486 rows, 5 columns
AbsenceIDDateEmployeeIDTypeDays
11 Jan 2025111Sick leave2
22 Jan 2025101Vacation9
33 Jan 2025127Sick leave4
43 Jan 2025127Sick leave10
54 Jan 2025142Sick leave2
66 Jan 2025104Sick leave4
76 Jan 2025118Vacation3
87 Jan 2025124Sick leave4
97 Jan 2025134Vacation6
1012 Jan 2025113Vacation7
1115 Jan 2025115Sick leave4
1216 Jan 2025117Sick leave2

Showing the first 12 of 486 rows.

Measures: [Absence Days]

Date 730 rows, 4 columns
DateYearMonthMonthName
1 Jan 202520251Jan
2 Jan 202520251Jan
3 Jan 202520251Jan
4 Jan 202520251Jan
5 Jan 202520251Jan
6 Jan 202520251Jan
7 Jan 202520251Jan
8 Jan 202520251Jan
9 Jan 202520251Jan
10 Jan 202520251Jan
11 Jan 202520251Jan
12 Jan 202520251Jan

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
EmployeeIDNameDepartmentIDHireDateLeaveDateSalaryEmploymentTypeStatus
101Sophie Lang11 Oct 202051500Full-timeActive
102Noah Walker11 Nov 202529600Part-timeActive
103Sophie Hayes11 Sep 202654100Full-timeActive
104Sam Price11 Aug 202460300Full-timeActive
105Ben Price11 Mar 201831 May 202666600Full-timeLeft
106Olivia Hughes11 Apr 202066000Full-timeActive
107Ben Bennett21 Nov 201244000Part-timeActive
108Jack Hughes21 Feb 201647600Full-timeActive
109Ben Hayes21 Apr 202131 Aug 202551000Full-timeLeft
110Lucy Clarke21 Oct 201957700Full-timeActive
111Ravi Ali21 Jul 202231 Mar 202548700Full-timeLeft
112Ben Foster21 Mar 201952100Full-timeActive

Showing the first 12 of 46 rows.

Department 6 rows, 3 columns
DepartmentIDDepartmentDivision
1AdministrationAdministration
2SalesSales
3ProductionOperations
4LogisticsOperations
5ITAdministration
6Customer ServiceSales
Absence 486 rows, 5 columns
AbsenceIDDateEmployeeIDTypeDays
11 Jan 2025111Sick leave2
22 Jan 2025101Vacation9
33 Jan 2025127Sick leave4
43 Jan 2025127Sick leave10
54 Jan 2025142Sick leave2
66 Jan 2025104Sick leave4
76 Jan 2025118Vacation3
87 Jan 2025124Sick leave4
97 Jan 2025134Vacation6
1012 Jan 2025113Vacation7
1115 Jan 2025115Sick leave4
1216 Jan 2025117Sick leave2

Showing the first 12 of 486 rows.

Measures: [Absence Days]

Date 730 rows, 4 columns
DateYearMonthMonthName
1 Jan 202520251Jan
2 Jan 202520251Jan
3 Jan 202520251Jan
4 Jan 202520251Jan
5 Jan 202520251Jan
6 Jan 202520251Jan
7 Jan 202520251Jan
8 Jan 202520251Jan
9 Jan 202520251Jan
10 Jan 202520251Jan
11 Jan 202520251Jan
12 Jan 202520251Jan

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".

Done: all six cases

Your course view shows which tasks are still open and where you request the "Power BI for HR" certificate.

Go to the course view

Back to case 5 or the course overview.

Write to us

Choose language

Select your preferred language