Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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)
)
)
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)
)
)
User | Count |
---|---|
128 | |
108 | |
99 | |
65 | |
62 |
User | Count |
---|---|
136 | |
113 | |
102 | |
71 | |
60 |