Forum Discussion
Show a Button to Only Certain Users
I've spent over 5 hours researching this and trying like a dozen different methods. I can't figure it out.
I have a button that takes a user to a SharePoint list that allows them to input an event so it shows up in a calendar on the dashboard.
I want this button to only be shown to specific users so not everyone can input events.
I've tried User Roles/Manage Roles but can't figure it out. Can someone help walk me through this?
I currently have a table that has the 10 emails of the users who should be able to see the button formatted like this:
| User Email | See Button |
| Email 1 | 1 |
| Email 2 | 1 |
| Email 3 | 1 |
| Email 4 | 1 |
What's the next step to set up the user roles and tie it to the button?
Hi Anonymous,
Unfortunately Power BI doesn't have a native "hide this visual/button" toggle, but there's a workaround that gets the job done. You can use the DAX code below to determine of an user is allow to see the button or not.
IsUserAllowToSeeButton = VAR _CurrentUPN = USERPRINCIPALNAME() RETURN -- Returns 1 or 0 CALCULATE( MAX('Table1'[Email See Button]), 'Table1'[UPN] = _CurrentUPN )Then you can use this measure in a new measure that returns a color code. When BLANK() is returned for authorized users, Power BI falls back to whatever the default color is in the format pane of the button. Otherwise the color is white, which will blend in with the background color, when the background color is also white.
ButtonVisibilityColor = IF( [IsUserAllowToSeeButton] = 1, BLANK(), "#FFFFFF" )You can use this measure for the conditional formatting of the fill, text and border color of the button.
But, the caveats of this solution is that people for whom the button is invisible can still click the button by accident or know where to click. There is currently no possibility to disable this button. If you would like this feature, please vote for this idea: Allow conditional disabling of a button - Microsoft Fabric Community
Hope this helps. If so, please give kudos 👍 and mark as Accepted Solution ✔️ to help others.
3 Replies
- nielsvdcSuper User
Hi Anonymous,
Unfortunately Power BI doesn't have a native "hide this visual/button" toggle, but there's a workaround that gets the job done. You can use the DAX code below to determine of an user is allow to see the button or not.
IsUserAllowToSeeButton = VAR _CurrentUPN = USERPRINCIPALNAME() RETURN -- Returns 1 or 0 CALCULATE( MAX('Table1'[Email See Button]), 'Table1'[UPN] = _CurrentUPN )Then you can use this measure in a new measure that returns a color code. When BLANK() is returned for authorized users, Power BI falls back to whatever the default color is in the format pane of the button. Otherwise the color is white, which will blend in with the background color, when the background color is also white.
ButtonVisibilityColor = IF( [IsUserAllowToSeeButton] = 1, BLANK(), "#FFFFFF" )You can use this measure for the conditional formatting of the fill, text and border color of the button.
But, the caveats of this solution is that people for whom the button is invisible can still click the button by accident or know where to click. There is currently no possibility to disable this button. If you would like this feature, please vote for this idea: Allow conditional disabling of a button - Microsoft Fabric Community
Hope this helps. If so, please give kudos 👍 and mark as Accepted Solution ✔️ to help others.
- Xian-ZuoFrequent Visitor
If your SharePoint list is just a hidden page, you only need to set a function in the button's page navigation, giving the correct page name when the email is in the list, and an empty value otherwise. The same applies to the button text display, and then by turning off the header icon, you can achieve the desired effect.
- danextianSuper User
Hi Anonymous
Shapes do not have a visual filter option so you can't use DAX to truly hide them. What you can do is to conditionally format the shape (fill, text, border). You can use this measure below
Transparent Button = VAR _hideButtonUsers = CALCULATETABLE ( VALUES ( users[user] ), KEEPFILTERS ( users[indicator column] = "hide" ) ) -- replace this with the actual tables of users who shouldnt see the button RETURN IF ( USERPRINCIPALNAME () IN _hideButtonUsers, "transparent" )Use this measure as field value in conditional formatting.
Note: the button is still there but blends with the background.