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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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