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

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

Reply
BradRose
Helper I
Helper I

Row Level security

Good Afternoon:

 

I am trying to use row level security with the ()username function.  I was able to create Measure for username I called it "Login" it returns the results as expected.  When I try and link the username measure to the ID it does not return any results.

 

[LANID] = [Login]

 

Any insights as to what I am doing wrong?  I have a feeling I missing a few steps

 

Brad

1 ACCEPTED SOLUTION

Hi @BradRose,

Within Power BI Desktop, username() will return a user in the format of DOMAIN\User and userprincipalname() will return a user in the format of user@contoso.com.

Within the Power BI service, username() and userprincipalname() will both return the user's User Principal Name (UPN). This looks similar to an email address.



As Matt has mentioned above, username() will return a user in different format within Power BI Desktop and Power BI service. So could you try using the formula below to see if it works?

Login = SUBSTITUTE ( USERPRINCIPALNAME (), "@contoso.com", "" )

In addition, here is a good article about Dynamic RLS in Power BI for your reference. Smiley Happy

 

Regards

View solution in original post

3 REPLIES 3
MattAllington
Community Champion
Community Champion

What format is the LANID?  Is it an email address or domain\username.  Be careful as the behaviour on powerbi.com and power bi desktop is different. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Matt:

 

LANID is a coulmn in our employee table is the just the username.  In my measure I have stipped out the domain to match the column in the employee table. 

 

Here is my measure   

Login = SUBSTITUTE(USERNAME(),"NESTLE\","")

 

Brad

Hi @BradRose,

Within Power BI Desktop, username() will return a user in the format of DOMAIN\User and userprincipalname() will return a user in the format of user@contoso.com.

Within the Power BI service, username() and userprincipalname() will both return the user's User Principal Name (UPN). This looks similar to an email address.



As Matt has mentioned above, username() will return a user in different format within Power BI Desktop and Power BI service. So could you try using the formula below to see if it works?

Login = SUBSTITUTE ( USERPRINCIPALNAME (), "@contoso.com", "" )

In addition, here is a good article about Dynamic RLS in Power BI for your reference. Smiley Happy

 

Regards

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.