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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to set row level security customer company code linked to login ID

Environment is Power BI embedded and Azure SQL

 

One table has all customer company data contain customer company code and users will access common Power BI Report. Login ID does not contain company code.

I want to show to user there company data that is match customer company code linked to login ID.

 

What should I do?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous,

 

For your scenario, you can set up your RLS fitler on company_code filed.

Lookup company_code based on current username, then use this as filter parameter to apply on company_code field.

 

Sample formula:

[company_code] =
LOOKUPVALUE ( 'Table'[company_code], 'Table'[login_Id], USERPRINCIPALNAME () )

12.PNG

 

Regards,

Xiaoxin Sheng

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous,

 

I'd like to suggest you to take a look at below link about RLS with username:

RLS with UserName()

 

Add company code to user table to link company id with username and use this column to create relationship to other tables. Then you can use logined users to achieve dynamic rls filter.

 

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Hi Xiaoxin.

 

Thank you for reply.  I tried to use RLS username() or userprincipalname() but the requeirments are racking my brain...

 

Table has data like below.

 

company_codelogin_Iddatedata
AAAuser01@contoso.com2018/1/110
AAAuser01@contoso.com2018/2/120
AAAuser02@contoso.com2018/1/110
BBBuser03@oslo.com2018/1/120
BBBuser04@oslo.com2018/1/130
CCC

user05@contoso.com

2018/2/140

 

Requirements.

-Customer company has multiple user. "user01" and "user02" can see data linked "AAA".

-Some users have same domain but other company like subsidiary. So, "user01" and "user02" do not see data linked "CCC". "user05" can see only data linked "CCC".

-Domain does not necessarily include a company name or code.

 

 

So, I might be able to solve this matter if I could use customer company code linked to loginID for condition.

 

Would you have any good ideas?

Anonymous
Not applicable

Hi @Anonymous,

 

For your scenario, you can set up your RLS fitler on company_code filed.

Lookup company_code based on current username, then use this as filter parameter to apply on company_code field.

 

Sample formula:

[company_code] =
LOOKUPVALUE ( 'Table'[company_code], 'Table'[login_Id], USERPRINCIPALNAME () )

12.PNG

 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors