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
harshagraj
Post Partisan
Post Partisan

Filter out using USERPRINCIPALNAME()

Hello all,

 

Please see the below data. When i publish the below view in the service if i login with "harsha@ab.com" i dont want to see 1st record and If an user login with "gururaj@ab.com" we dont need 2nd record.

 

NameEmailScores
Harshaharsha@ab.com1
Gururajgururaj@ab.com2
Kingking@ab.com3

 

I tried creating a column as 
If(email=USERPRINCIPALNAME(),1,0)

 

But since i connected my dashboard as directquery i get an error.

Please help me to filter out the data.

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You can create an RLS role with the rule

[email] <> USERPRINCIPALNAME()

 

Once you have created a role, anyone you want to view the report must be assigned to a role. This is the intended functionality and there isn't a way to avoid assigning roles if you want to use RLS.

 

See the documentation and prior discussion here:
https://community.powerbi.com/t5/Desktop/Row-Level-Security-All-Users/m-p/253154

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

HI @harshagraj,

You can refer to the following link to know how to set a dynamic RLS based on username:

Solved: RLS with UserName() - Microsoft Power BI Community

Notice: please create a measure with USERNAME and USERPRINCIPALNAME functions to confirm which one is suitable for your user table information.

Difference between USERNAME() and USERPRINCIPALNAME() in Power BI Dax - SPGuides

Regards,

Xiaoxin Sheng

AlexisOlson
Super User
Super User

You can create an RLS role with the rule

[email] <> USERPRINCIPALNAME()

 

Once you have created a role, anyone you want to view the report must be assigned to a role. This is the intended functionality and there isn't a way to avoid assigning roles if you want to use RLS.

 

See the documentation and prior discussion here:
https://community.powerbi.com/t5/Desktop/Row-Level-Security-All-Users/m-p/253154

amitchandak
Super User
Super User

@harshagraj , You can use USERPRINCIPALNAME only in a measure. I doubt you can use that in a column

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello can someone help on this topic
@Greg_Deckler @AlexisOlson @PhilipTreacy @v-zhangti 

Also if i have to create a measure then how do i aggregate Name column?

If(???(Name)=USERPRINCIPALNAME(),1,0)

Kindly help.

 

Thanks for the reply but how do i solve this problem?

I also tried creating a role like NAME<>LOOKUP(NAME,EMAIL,USERPRINCIPALNAME())

This is also not working properly because i dont have a speicific AD gropu to assign.

 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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