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
IzBell
Frequent Visitor

Configure Row Level Security based on Country of the logged-in User

Hi everyone,

I am wondering if anyone can help with the DAX for the Manager Roles in Power BI Desktop please.

 

Logic: The RLS where the logged-in user can see data for the Country OR Department they are based in, except their own records.

 

For example: I have two tables [Employee Table] and [Sale Table]

  • [Employee Table]
Employee IDEmailCountryDepartment
1aa@x.comAustraliaHR
2ab@x.comCanadaH&S
3ac@x.comThailandFinance
4ad@x.comSouth AfricaPayroll

 

  • [Sale Table]
DateEmployee IDEmailCountryDepartment Sales Amount 
Sep-241aa@x.comAustraliaHR $                    1,000
Sep-242ab@x.comCanadaH&S $                         500
Sep-243ac@x.comThailandFinance $                    1,500
Sep-244ad@x.comSouth AfricaPayroll $                         300
Sep-245ae@x.comAustraliaHR $                    1,500
Sep-246af@x.comCanadaHR $                         200
Sep-247ag@x.comAustraliaHR $                    4,000
Oct-241aa@x.comAustraliaHR $                         500
Oct-242ab@x.comCanadaH&S $                         300
Oct-243ac@x.comThailandFinance $                    4,000
Oct-244ad@x.comSouth AfricaPayroll $                         500
Oct-245ae@x.comAustraliaHR $                    2,500
Oct-246af@x.comCanadaHR $                    4,010
Oct-247ag@x.comAustraliaH&S $                    1,000

 

If the User 1 (aa@x.com) logs in, they can see data for Australia OR HR, except their own records.
Expected Result:

DateEmployee IDEmailCountryDepartment Sales Amount 
Sep-245ae@x.comAustraliaHR $                    1,500
Sep-246af@x.comCanadaHR $                         200
Sep-247ag@x.comAustraliaHR $                    4,000
Oct-245ae@x.comAustraliaHR $                    2,500
Oct-246af@x.comCanadaHR $                    4,010
Oct-247ag@x.comAustraliaH&S $                    1,000

 

Your help would be much appreciated.

Many thanks,

IzBell

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @IzBell ,

 

I think you can try code as below.

(
[Country] ==  CALCULATE(MAX(Employee[Country]),FILTER(ALLSELECTED(Employee),Employee[Email] = USERPRINCIPALNAME()))
|| 
[Department] ==
CALCULATE(MAX(Employee[Department]),FILTER(ALLSELECTED(Employee),Employee[Email] = USERPRINCIPALNAME()))
)
&&
[Email] <> USERPRINCIPALNAME()

vrzhoumsft_1-1730685570432.png

Result is as below. (View as aa@x.com)

vrzhoumsft_0-1730685544413.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @IzBell ,

 

I think you can try code as below.

(
[Country] ==  CALCULATE(MAX(Employee[Country]),FILTER(ALLSELECTED(Employee),Employee[Email] = USERPRINCIPALNAME()))
|| 
[Department] ==
CALCULATE(MAX(Employee[Department]),FILTER(ALLSELECTED(Employee),Employee[Email] = USERPRINCIPALNAME()))
)
&&
[Email] <> USERPRINCIPALNAME()

vrzhoumsft_1-1730685570432.png

Result is as below. (View as aa@x.com)

vrzhoumsft_0-1730685544413.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Amazing. This is working as expected. Thank you very much Rico. Much apprecaited.
Kind regards,

IzBell

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