Forum Discussion

SnoekLaurens's avatar
SnoekLaurens
Advocate I
1 year ago
Solved

UDF User Data Function - error when user has not access to function

I have created some UDF functions for writeback to Fabric warehouse from a Power BI report. This is working as expected. Only thing that I'm not able to manage is an error message of some kind when ...
  • Nasif_Azam's avatar
    Nasif_Azam
    1 year ago

    Hey SnoekLaurens ,

    Since you're using the new native writeback functionality in Microsoft Fabric with UDF and not using Power Automate or Power Query, the solution should focus on enhancing the button’s behavior directly in Power BI. Steps to Add Error Handling to the Button:

     

    1. Create a DAX Measure for User Permissions: First, create a DAX measure that checks whether the current user has the necessary permissions. This could be based on roles or a user table that tracks access levels.

       

      UserHasPermission = 
      IF(
          CONTAINS(
              UserPermissions[UserID], 
              UserPermissions[UserID], USERNAME()
          ), 
          TRUE, 
          FALSE
      )
    2. Set the Button Action Based on the Permission Check:

      • You can use the UserHasPermission measure in the button’s Action property to control whether the UDF is triggered.

      • If the user does not have permission, you can set the button action to None or show a message indicating lack of access.

    3. Use a Dynamic Tooltip/Message: You can also configure the button’s tooltip or dynamic text to inform the user about their permission status.

      ButtonMessage = 
      IF(
          [UserHasPermission] = TRUE(),
          "Click to writeback to Fabric Warehouse",
          "You do not have permission to perform this action"
      )

       

    4. Provide Feedback on the Button: Set the Visible property of the button based on the permission measure:

      ButtonVisible = 
      IF([UserHasPermission] = TRUE(), TRUE(), FALSE())

      This way, the button can either be visible or hidden depending on the user's access level.

    Implement these DAX measures in your Power BI report and link them to the button properties like Action, Visible, and Tooltip to manage user interactions based on their permissions.

     

     

    If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.


    Best Regards,
    Nasif Azam