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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
YGL18
Frequent Visitor

RLS tabular model filter does not recognize Username()

In Visual Studio I add the filter below to the 'Staff Education Organization' Table.

It only works if I add email address directly in the filter such as "blabla@gmail.com" instead of USERNAME().

but it does not work if I use USERNAME() function.

 

What can be the problem?

 

= 'Staff Education Organization'[SchoolID] =

          LOOKUPVALUE('Staff Education Organization'[SchoolID],

                                'Staff Education Organization'[ElectronicMailAddress],

                                 USERNAME()

                               )

 

Model FilterModel Filter

1 ACCEPTED SOLUTION
YGL18
Frequent Visitor

This is what we found:

 

Username() function is not returning clean email if email is added to AAD as a guest.

 

1-3-2019 12-21-08 PM.png

 

 

It attaches this string at the front:

 

live.com#

 

View solution in original post

5 REPLIES 5
TomMartens
Super User
Super User

Hey,

 

maybe you have to consider that USERNAME() might return something different depending on the environment:

 

a) Power BI Desktop
here USERNAME most likely will return something similar to domain\accountname whereas

b) Power BI Service
here USERNAME will return something like someone@domain.com

 

Hopefully, this gets you an idea.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hey Tom,

 

Thank you for the answer. I deploy the model from VS to Azure and users log in from the add.powerbi.com. As I understand it right, we are using Power BI Service and Usename( ) suppose to return email address which is not working for me. Can you please explain more how to make this work, I am very new to it.

 

Thank you,

Julia

Hey Julia,

 

this article may guide you:

https://community.powerbi.com/t5/Integrations-with-Files-and/Azure-Analysis-Services-Azure-AD-and-RL...

 

I think an essential part will be to add user to the Azure AD

https://docs.microsoft.com/en-us/azure/active-directory/fundamentals/add-users-azure-active-director...

 

But maybe it will be a good idea to consult your Azure AD administrator, but maybe that's you 🙂

 

Regards,

Tom 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thank you for the useful article, Tom

 

I have two emails added to Azure.

 

The first email is my work account and it’s not an Admin for AAD/Azure, but it IS an Admin (“Owner”) for all the associated resources. So I guess the firsl email will not work for testing.

 

The second email is added as a guest account.

Whould RLS work on the second email?

 

AzureAccounts.png

YGL18
Frequent Visitor

This is what we found:

 

Username() function is not returning clean email if email is added to AAD as a guest.

 

1-3-2019 12-21-08 PM.png

 

 

It attaches this string at the front:

 

live.com#

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.