Forum Discussion

ray_codex's avatar
ray_codex
Resolver II
1 year ago
Solved

RLS on different hierarchy levels

Hi,   I have this RLS question that I can't solve. In our organisation, because of complaincy, we want users to be able to see their own submitted hours but not the hours of other users. But, and t...
  • v-csrikanth's avatar
    1 year ago

    Hi ray_codex 
    Sorry for the late response.
    Could you try the below suggested that might resolve your issue effectively.
    ***********************************************************************

    VAR CurrentUser = USERPRINCIPALNAME()
    VAR UserPermission =
    LOOKUPVALUE(SecurityTable[Permissiontype], SecurityTable[Email], CurrentUser)
    VAR CurrentUserID =
    LOOKUPVALUE(SecurityTable[UserID], SecurityTable[Email], CurrentUser)
    VAR DistinctUsersInContext = CALCULATE(DISTINCTCOUNT(factHours[UserID]), ALLSELECTED(factHours))

    RETURN
    IF (
    UserPermission = "All",
    TRUE(),
    IF (
    DistinctUsersInContext = 1,
    factHours[UserID] = CurrentUserID,
    TRUE()
    )
    )
    ***********************************************************************

    If the above information helps you, please give us a Kudos and marked the Accept as a solution.

    Best Regards,
    Community Support Team _ C Srikanth.