Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 months ago
Solved

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 even...
  • nielsvdc's avatar
    5 months ago

    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.