This is about the USERPRINCIPALNAME function, which shows the user name of currently logged user.

It is typically used for RLS authorization - thanks to it users only can see their own data (rows).

USERPRINCIPALNAME has no arguments, it is always like this:

  • =USERPRINCIPALNAME()

This function can´t be written into a column - it only can be used as a measure or for role definition.

You should know, that this function provides different results in Power BI Desktop and in powerbi.com. In Desktop it provides the name of PC, in powerbi.com it provides the login (email) of currently logged user.

If you use it in measure and put it into a visual, you always know who is logged or the name of PC (on Power BI Desktop):

But use for RLS is much more interesting. Lets say there is this table containing sales data:

In this table, every account manager should only see his items.

Lets create a role:

Then, in portal, assign it to everybody who we will share this report with.

From now, everyone sees his own items - since for different persons the PRINCIPALUSERNAME functions provides different results.

It can´t be tested on desktop - because on desktop the USERPRINCIPALNAME can´t provide the users login.

Leave a Reply

Your email address will not be published.

*

clear formPost comment