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.
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)
)
)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
95 | |
77 | |
65 | |
53 |
User | Count |
---|---|
144 | |
105 | |
102 | |
89 | |
63 |