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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Lightbot
New Member

USERNAME() and USERNAMEPRINCIPAL() not working on published report.

Hi,

 

I'm trying to implement user based filtering using RLS as described here:

 

https://community.powerbi.com/t5/Community-Blog/Different-approach-to-Dynamic-Row-Level-Security/ba-...

 

But as a test I have 2 measures and 2 custom columns, with one each of USERNAME() and USERPRINCIPALNAME(), the measures work in the desktop, but all 4 are showing errors on the published report.

 

Am I using these wrong or are they broken?

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

When I signed into the report yesterday the measures were working fine, so my initial problem is solved.

 

Thanks for the info about the admin rights, I had wondered that but the confirmation has helped testing.

 

I've managed to solve my security problem using a simpler RLS:

 

[Category] = LOOKUPVALUE(security_mapping[Category], security_mapping[Email], USERNAME())

 

Thanks for the help.

View solution in original post

5 REPLIES 5
Seth_C_Bauer
Community Champion
Community Champion

@Lightbot Have you applied users to the roles in the Service? Go to the dataset -> Security and you need to apply different users or groups to the roles you've created.


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG
Anonymous
Not applicable

So...  are you saying for the filter on User() I have to add ALL users to the Row-Level Security?  Wow!  that is over 250 people!   Or, just those with advanced rights in the workspace?

@Seth_C_BauerI've only applied myself at the moment, but I shouldn't need that for a single field table that just shows USERNAME() from a calculated column or measure should I?

 

Thanks

Anonymous
Not applicable

Hi @Lightbot,

What error message do you get in Power BI Service? Based on my test, when I create column using the formula in the blog, I get error message” CUSTOMDATA, USERNAME and USERPRINCIPALNAME functions are not supported in calculated tables/columns. These functions may only be used in Measures or in the AllowedRowsExpression”.

Security_Category = NOT(ISBLANK(LOOKUPVALUE(security_mapping[CATEGORY],security_mapping[CATEGORY],[Category],security_mapping[EMAIL],USERNAME())))

In addition, you apply yourself as RLS role member in Power BI Service, right? Please note that by default you have Admin rights to the model when you create the Power BI Desktop file and upload it, you will be able to see everything in the reports, thus to check if the RLS works as expected, please share your dashboard with other user who has limited access to data in reports, for more details, please review this similar blog.

 

Thanks,
Lydia Zhang

Hi @Anonymous,

 

When I signed into the report yesterday the measures were working fine, so my initial problem is solved.

 

Thanks for the info about the admin rights, I had wondered that but the confirmation has helped testing.

 

I've managed to solve my security problem using a simpler RLS:

 

[Category] = LOOKUPVALUE(security_mapping[Category], security_mapping[Email], USERNAME())

 

Thanks for the help.

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