Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Hyuna_8000
Helper I
Helper I

Hierarchical row level security Dax using Pathcontains

Hi everyone,

 

I need to create a new role in Manage Roles to set up a row level security according to our hierarchy. I tried to use Pathcontains in the dax but still can't get the code working correctly. Appreciated if anyone can point me the right direction.

 

Here is my sample data:

Employee NameEmailHierarchy
Tom GlandTom.Gland@example.com/Tom Gland
Lily WyLily.Wy@example.com/Tom Gland/Lily Wy
Incy WincyIncy.Wincy@example.com/Tom Gland/Lily Wy/Incy Wincy
Kent FordKent.Ford@example.com/Tom Gland/Lily Wy/Incy Wincy/Kent Ford
Russell BarrowRussell.Barrow@example.com/Tom Gland/Lily Wy/Incy Wincy/Kent Ford/Russell Barrow
Mary LanceMary.Lance@example.com/Tom Gland/Lily Wy/Incy Wincy/Kent Ford/Russell Barrow/Mary Lance
Beatrix TongBeatrix.Tong@example.com/Tom Gland/Lily Wy/Incy Wincy/Kent Ford/Russell Barrow/Mary Lance/Beatrix Tong

 

Basically when employees login using their email in PowerBI, they should be able to see every employee reporting to them, directly and indirectly. For example, Kent Ford should see himself, Russell Barrow, Mary Lance, and Beatrix Tong in the dataset when he logs in. 

 

This is my first DAX, it only returns the employee's record themselves, for example for Kend Ford, only the row with his name was visible to him when he logged in:

PATHCONTAINS(Employee[Hierarchy],
MaxX(
Filter(
Employee,
[Email]=USERPRINCIPALNAME()
)
,Employee[Hierarchy]
)
)



This is my second dax, but it returns nothing:
VAR EmployeeName = LOOKUPVALUE(Employee[Employee Name], Employee[Email], USERPRINCIPALNAME())
RETURN
PATHCONTAINS(Employee[Hierarchy], EmployeeName)

1 ACCEPTED SOLUTION

Thank you, the data comes as forward slash so I converted it to the Pipe symbol, the the following DAX works!
VAR EmployeeName = LOOKUPVALUE(Employee[Employee Name], Employee[Email], USERPRINCIPALNAME())
RETURN
PATHCONTAINS(Employee[Hierarchy], EmployeeName)

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

Use the Pipe symbol, not the forward slash. Use the email address in the hierarchy, not the name.

 

Then all you need is 

PATHCONTAINS(Employee[Hierarchy],USERPRINCIPALNAME() )

Thank you, the data comes as forward slash so I converted it to the Pipe symbol, the the following DAX works!
VAR EmployeeName = LOOKUPVALUE(Employee[Employee Name], Employee[Email], USERPRINCIPALNAME())
RETURN
PATHCONTAINS(Employee[Hierarchy], EmployeeName)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.