Greetings for the day!
I need a little help with my Power BI report. I have a table visual with the following data:
I want to implement a feature where, when a user logs in, they should not see their own data but should be able to see the data of other users.
For example: See table below
If Sujoy logs in, he should not see his data but should see the data for Rahul, Suresh.
Similarly, if Rahul logs in, he should not see his data but should see the data for Sujoy, Suresh.
I am already retrieving the email address in DAX using the following code:
//VAR _user = USERPRINCIPALNAME()
How can I pass this variable to the table visuals in my PBIX file to achieve the desired functionality?
Thank you for your assistance!
Email Id First Name Last Name Rating
[email protected] Sujoy Das 5
[email protected] Rahul Dravid 2
[email protected] Suresh Raina 3
To implement this functionality in Power BI you can use row-level security (RLS) combined with a DAX filter on the table visual.
-
Ensure your data table has a column that contains the user email or username (
UserEmail
) that matches the output ofUSERPRINCIPALNAME()
. -
Create a DAX measure to filter data. Add a measure that checks the currently logged-in user against the data and excludes rows where the user email matches:
IsNotCurrentUser = IF( [UserEmail] <> USERPRINCIPALNAME(), 1, 0 )
-
Filter your table visual using the measure:
Apply theIsNotCurrentUser
measure to your table visual.- Add the measure to the table.
- Use the “Filter Pane” in Power BI to filter the visual where
IsNotCurrentUser = 1
.
-
Set up RSL (optional)
If you’d like to enforce this at a security level (so users cannot bypass it):- Go to Modeling > Manage Roles.
- Create a new role, e.g.,
ExcludeOwnData
, and add the following filter to the table:[UserEmail] <> USERPRINCIPALNAME()
- Assign this role to users in the Power BI Service.