Introduction There are scenarios where username or userprincipalname required to use to give access but to use USERPRINCIPALNAME()dynamically and come with the different possibility.
Scenario 1 : In any Organisation each employee belongs to different department and have access as per his designation. An Executive always have access to all data which is related to his employee and a Manager to his department but not to the data which belongs to Executive and similarly Lower Level employee will have access to his data only.
Access Definition: Access definition
Scenario 2. multiple users exists in the same row.(Additional Example how we can use the USERPRINCIPALNAME( ))
Steps to follow to solve above scenarios
STEP 1 Create or Import your user table and Fact table and make sure there must not be any relationship between the user table and fact table .
STEP 2 Create a Flag column in Fact tables. In this case created a flag in Charged Hours.
Create RLS with Role User and use below codes respectively for respective Tables. For Users use below dax: