Capturing the current user context of Power BI content
The foundation of dynamic user and visibility in Power BI is the 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 other DAX measures, such as retrieving the UPN prefix and suffix and even filtering other measures per the final recipe in this chapter, Avoiding manual user clicks with user-based filtering logic.
In this recipe, DAX measures are added to a data model to dynamically retrieve the UPN, as well as its prefix and suffix. Additional detail on authentication in Power BI and the USERNAME()
function, an alternative dynamic DAX function which also retrieves the UPN...