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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Aa1997
New Member

Create a role that is filter the data depends on the user’s network id ( shows user’s dept info)

Greetings All, 

 

I'm new in Power Bi and I'm facing an issue trying to create a rolr, 

 

please assist if you know the correct DAX to use, 

 

I want to create a role that take the current loged in used network ID then go to the (user information table) look up his department then filter all the dashboard with only information of employees of his department

 

I hope my question is clear,

please note that the (user info table) has relationships with the other tables in the dashboard. 

appreciate your help 🙏 

1 ACCEPTED SOLUTION
bcdobbs
Community Champion
Community Champion

I think my above suggest solution is the best way forward from a performance perspective however if you really want to avoid a second table you could use this in the role:

 

VAR AllowedDepts = 
CALCULATETABLE (
VALUES ( User[Department] ),
User[UserName] = USERPRINCIPALNAME()
)
RETURN
User[Department] IN AllowedDepts

 

You can see this here:

Example PBIX 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

7 REPLIES 7
bcdobbs
Community Champion
Community Champion

What you're looking to do is called Dynamic RLS. 
A good starting point is:

https://radacad.com/dynamic-row-level-security-with-power-bi-made-simple



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Yes i know i have to create dynamic RLS 

but I believe i must use DAX to filter the tables depending on current user department 

please assist if you know the answer 

thank you

bcdobbs
Community Champion
Community Champion

I might be missing something I. Your requirement but the details are in the link I sent.

 

You create your role in power bi desktop and within the role apply a filter to your user table. Something along the lines of:

 

UserTable[User] = UserPrincipalName()



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

I'm sorry for not providing you with the details 

 

I have around 6000 employees data in the table

i want to create a dynamic role where each user able to view only the data of the employees in his department. 
let's assume that the table name is user info and it contains 5 columns ( emp name, emp ID, emp department, emp job title, and emp age) 

So I want to create a role whre it looks for current logedin user ID ( in emp ID column) 

then looks what is his department ( emp department column) 

then filter all the data for this department only 

so the user won't be able to view other employees from different departments data. 

I used username() for the network ID but I'm stuck with looking for the department then filter the rows depending on this department 

 

I hope you help me

appreciate ur efforts 

bcdobbs
Community Champion
Community Champion

Ok!

 

Couple of options. An easy approach is:

 

In power query duplicate you user table, remove columns so you're left with the username and department. (Remove duplicates if needed).

 

Then in your model relate your new table to existing table based on department. It will be many to many; set it so your new table filters the user table (really important).

 

Then apply the user filter to your new table. 

There are other options but iMd try that first.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
bcdobbs
Community Champion
Community Champion

I think my above suggest solution is the best way forward from a performance perspective however if you really want to avoid a second table you could use this in the role:

 

VAR AllowedDepts = 
CALCULATETABLE (
VALUES ( User[Department] ),
User[UserName] = USERPRINCIPALNAME()
)
RETURN
User[Department] IN AllowedDepts

 

You can see this here:

Example PBIX 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Thank you very much appreciate it 🙏

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.