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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
aka
Helper II
Helper II

Enabling Row Level security

how to enable row level security in power bi ?

 

1 ACCEPTED SOLUTION
Peter_R
Resolver II
Resolver II

It's a rather involved topic - best place would be to review the published documentation https://powerbi.microsoft.com/en-us/documentation/powerbi-admin-rls/ and then make some attempts at implementing it for your purposes.

One hint I can point out if you're looking at securing the current user against a table entry is that the USERNAME() function to obtain the current user returns a different format when using the desktop vs published to the service, which presents a challenge when parsing it to get the name.  Even though RLS only applies to published visuals, it can be helpful to display the name of the user somewhere, even for debugging purposes. I use this measure formula to parse the user name into a First.Last format which works from both the desktop and the service:

CurrentUserName =
/*Parse the result of the USERNAME function call to return an uppercase name in the form first.last, which is how names are stored in the SAP table. Note that the USERNAME function returns a different format when called from the PBI Desktop than when called from the PBI Service */
VAR CurrentUser = USERNAME()
VAR PosnOfUserName_domain = SEARCH("\", CurrentUser, 1, 0)
VAR PosnOfUserName_email = SEARCH("@", CurrentUser, 1, 0)
RETURN UPPER(
IF(PosnOfUserName_domain > 0
, MID(CurrentUser, PosnOfUserName_domain + 1, LEN(CurrentUser) - PosnOfUserName_domain)
, LEFT(CurrentUser, PosnOfUserName_email - 1)
)
)

View solution in original post

1 REPLY 1
Peter_R
Resolver II
Resolver II

It's a rather involved topic - best place would be to review the published documentation https://powerbi.microsoft.com/en-us/documentation/powerbi-admin-rls/ and then make some attempts at implementing it for your purposes.

One hint I can point out if you're looking at securing the current user against a table entry is that the USERNAME() function to obtain the current user returns a different format when using the desktop vs published to the service, which presents a challenge when parsing it to get the name.  Even though RLS only applies to published visuals, it can be helpful to display the name of the user somewhere, even for debugging purposes. I use this measure formula to parse the user name into a First.Last format which works from both the desktop and the service:

CurrentUserName =
/*Parse the result of the USERNAME function call to return an uppercase name in the form first.last, which is how names are stored in the SAP table. Note that the USERNAME function returns a different format when called from the PBI Desktop than when called from the PBI Service */
VAR CurrentUser = USERNAME()
VAR PosnOfUserName_domain = SEARCH("\", CurrentUser, 1, 0)
VAR PosnOfUserName_email = SEARCH("@", CurrentUser, 1, 0)
RETURN UPPER(
IF(PosnOfUserName_domain > 0
, MID(CurrentUser, PosnOfUserName_domain + 1, LEN(CurrentUser) - PosnOfUserName_domain)
, LEFT(CurrentUser, PosnOfUserName_email - 1)
)
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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