Capturing Current User Context
The foundation of dynamic user security and visibility in Power BI is the ability to extract the user principal name (UPN) or login credential of the business user connected to content in the Power BI service. The USERPRINCIPALNAME
DAX function retrieves this text value and thus enables filter expressions to be applied to the tables of a model in security roles. In addition to RLS roles, which override and impact all DAX measures of a dataset, the UPN or "current user" text value can be used by DAX measures to retrieve the UPN prefix and suffix, or filter other measures.
In this recipe, DAX measures are added to a data model to dynamically retrieve the UPN as well as the UPN's prefix and suffix. Additional detail on authentication in Power BI and the USERNAME
function, an alternative dynamic DAX function that also retrieves the UPN in the Power BI service, is also covered.
Getting ready
To prepare for this recipe, follow these...