Forum Discussion
UDF User Data Function - error when user has not access to function
- 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:
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 )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.
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" )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
Hi SnoekLaurens
Thank you for reaching out to the Microsoft Fabric Forum Community.
Nasif_Azam thank you so much for your inputs.
SnoekLaurens - I hope the information shared was helpful to you. If your question has been answered, kindly mark the most relevant reply as the Accepted Solution. This small action can make a big difference for others who are looking for the same solution.