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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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 @v-yuezhe-msft,

 

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

@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

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

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yuezhe-msft,

 

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors