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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
rdantas
Frequent Visitor

data filter by username

Hello! I want to filter date on my report, by the username logged on. In my database, I have the username. So I wanna compare the username logged on with the username in the database. I want the username logged on only see the lines with your email on the database.

 

user1@mail.com must see only the lines 1 and 2, so on...

 

How can I do this with RLS?

 

rdantas_0-1711046509136.png

 

3 ACCEPTED SOLUTIONS
Bipin-Lala
Super User
Super User

Hi @rdantas,

 

What you are trying to implement is called Dynamic RLS in Power BI, which is restricting data for the users, based on their login credentials.

 

Although I would have tried explaining Dynamic RLS here, but we already have some excellent resources available, which can help you with implementing your requirements. Please refer to the following links - 

Let me know if the above links help you out. In case they don't, could you please elaborate on your question a bit, I will try to provide a solution here only. All the best!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


Regards,

Bipin Lala | Business Intelligence Developer



View solution in original post

lbendlin
Super User
Super User

Read about dynamic RLS and USERPRINCIPALNAME()   (don't use USERNAME() )

View solution in original post

Anonymous
Not applicable

Hi @rdantas ,

 

lbendlin is right on the money. Let me take you through the specifics.

 

Be aware that username() has the format of DOMAIN\username within Power BI Desktop. Within the Power BI service and Power BI Report Server, it's in the format of the user's User Principal Name (UPN). Alternatively, you can use userprincipalname(), which always returns the user in the format of their user principal name, username@contoso.com.

 

You cannot assign a user to a role in Power BI Desktop. Assign users in the Power BI service. Dynamic security in Power BI Desktop can be enabled by using the username() or userprincipalname() DAX functions and configuring the correct relationship.

 

Please follow these steps:

 

Open the report in Power BI Desktop.

 

Navigate to the Modeling tab and select Manage roles.

 

Create a new Role, for example, name it Role1.

 

Enter the DAX expression on the right side as shown below.

 

Save the role.

vhuijieymsft_0-1711075588494.png

 

In the Modeling tab, select View as.

 

Select the Role1 you just created.

vhuijieymsft_1-1711075723889.png

 

I am testing this on Power BI Desktop in a virtual machine, so my userprincipalname is in "domain\username" format, which should not be wrong in Power BI Service.

 

If you are not sure, you can create a measure:

 

measure = userprincipalname()

 

 

And then drag it to the Card page to display it so you know your current userprincipalname.

 

Successful validation looks like this:

vhuijieymsft_2-1711075723891.png

 

Once you are satisfied with the settings, publish the report to Power BI Services.

 

In the Power BI service, you can assign the appropriate users to the created roles.

 

For a more detailed guide to setting up RLS, see the official documentation here:

Row-level security (RLS) with Power BI - Power BI | Microsoft Learn

 

The pbix file is attached.

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @rdantas ,

 

lbendlin is right on the money. Let me take you through the specifics.

 

Be aware that username() has the format of DOMAIN\username within Power BI Desktop. Within the Power BI service and Power BI Report Server, it's in the format of the user's User Principal Name (UPN). Alternatively, you can use userprincipalname(), which always returns the user in the format of their user principal name, username@contoso.com.

 

You cannot assign a user to a role in Power BI Desktop. Assign users in the Power BI service. Dynamic security in Power BI Desktop can be enabled by using the username() or userprincipalname() DAX functions and configuring the correct relationship.

 

Please follow these steps:

 

Open the report in Power BI Desktop.

 

Navigate to the Modeling tab and select Manage roles.

 

Create a new Role, for example, name it Role1.

 

Enter the DAX expression on the right side as shown below.

 

Save the role.

vhuijieymsft_0-1711075588494.png

 

In the Modeling tab, select View as.

 

Select the Role1 you just created.

vhuijieymsft_1-1711075723889.png

 

I am testing this on Power BI Desktop in a virtual machine, so my userprincipalname is in "domain\username" format, which should not be wrong in Power BI Service.

 

If you are not sure, you can create a measure:

 

measure = userprincipalname()

 

 

And then drag it to the Card page to display it so you know your current userprincipalname.

 

Successful validation looks like this:

vhuijieymsft_2-1711075723891.png

 

Once you are satisfied with the settings, publish the report to Power BI Services.

 

In the Power BI service, you can assign the appropriate users to the created roles.

 

For a more detailed guide to setting up RLS, see the official documentation here:

Row-level security (RLS) with Power BI - Power BI | Microsoft Learn

 

The pbix file is attached.

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

lbendlin
Super User
Super User

Read about dynamic RLS and USERPRINCIPALNAME()   (don't use USERNAME() )

Bipin-Lala
Super User
Super User

Hi @rdantas,

 

What you are trying to implement is called Dynamic RLS in Power BI, which is restricting data for the users, based on their login credentials.

 

Although I would have tried explaining Dynamic RLS here, but we already have some excellent resources available, which can help you with implementing your requirements. Please refer to the following links - 

Let me know if the above links help you out. In case they don't, could you please elaborate on your question a bit, I will try to provide a solution here only. All the best!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


Regards,

Bipin Lala | Business Intelligence Developer



Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors