Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
1 year ago
Solved

Conditional Visibility of Objects

Good afternoon Need to show and hide a graffiti in Power BI-visual based on a certain role, Can we achieve it? To my knowledge, conditional visibility is available in Power BI using slicer...
  • v-saisrao-msft's avatar
    v-saisrao-msft
    1 year ago

    Hi Syndicate_Admin,

    You can dynamically control the visibility of a visual (graffiti) in Power BI based on the user's role, without using slicers or bookmarks. This can be done through Row-Level Security (RLS) and a Measure-Based Visual Filter. Thank you Deku, for your insights. 

    • In Power BI, navigate to Model View, select Manage Roles, and create a new role (e.g., "Admin"). To filter data based on the logged-in user, use USERPRINCIPALNAME(). If you have a UserRoles table with [UserEmail] and [Role] columns, apply the RLS rule: [UserEmail] = USERPRINCIPALNAME()This ensures users see only the data relevant to their assigned role.  
    • Create a DAX measure to control the visibility of the graffiti visual:  

                  ShowGraffiti = IF(SELECTEDVALUE(UserRoles[Role]) = "Admin", 1, 0)  

    • This measure returns 1 to display the visual if the user has the "Admin" role; otherwise, it returns 0, effectively hiding it.  
    • In Power BI, select the graffiti visual, then drag the ShowGraffiti measure into the Filters pane. Set the filter condition to Show items where ShowGraffiti = 1 to ensure the visual is displayed only for users with the appropriate role. 

      

    Please refer to the below link for your reference: 

    Solved: Hide and Show visuals based on condition - Microsoft Fabric Community  

      

    If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.  

    Thank you.