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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anmolgan
Post Prodigy
Post Prodigy

How to Create A Dax for RLS?

I have a column named company ID that contains various comapnies with differnet employes in them, I need a DAX Query which will give data A/Q to the Company id, suppose if there are 3 employes inside a company and each of them have a companyid 1 then I they should able to see the reports of each other but they cannot be able to see the reports of comanyid 2 and 3, how this can be achived?

I know I can do this by creating different Roles for each companyid, but how can this be achived if I want this to be built in one particular role???

1 REPLY 1
v-yuezhe-msft
Employee
Employee

@Anmolgan,

Create the following tables in your scenario, and create relationship among these  tables and your data table.

1.UserCompany table contains two fields(user email address , company id)
2. Users table contains a field(unique user email address)
3. Company table contains unique company id

Then you can add DAX filter "Users[user]=username()" in the Users table, this way, you can achieve dynamic Row level security. There is a blog for your reference.

https://www.kasperonbi.com/power-bi-desktop-dynamic-security-cheat-sheet/

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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