Run a user data function from a Power BI button

Add a button to the report and set its action to Data function. Choose the Fabric function and map each parameter to a report value, such as text entered in an input slicer. The function must return text. Publish the report and test the button with an account that has permission to run it.

Analysts · ·

The problem

You have a user data function that writes to a Fabric data source. Now a report reader has to trigger it with a click, with the row they selected and the value they typed. The button settings are easy to get wrong, and the failures show up only as a short message in the published report. This Pattern is for report authors who connect the two.

What is generally available and what is not

  • Translytical task flows: generally available since the March 2026 Power BI update (2.152.882.0), per Microsoft’s update archive.- Optional parameters, default values and numeric input slicers: generally available in May 2026. Data function details in the button formatting pane: September 2026.
  • The Cosmos DB in Fabric guide still says “public preview”. That page differs from the Power BI pages.
  • Checked 2026-11-29. The input slicer carries no preview label in the pages read.

Steps

Flow from selecting a row and typing a value, to selecting the button. The outcome is either a success message with a refresh, or Something went wrong with View details. Four boxes list the common causes.

From click to result, and the four usual reasons for a failure.

These steps follow Microsoft’s tutorial: a table of product models, an input slicer for a new description and a button that calls the function from Pattern 14.

  1. Connect the report to the data. In Power BI Desktop create a report, select OneLake catalog, then SQL database, pick your database and connect. In Navigator load SalesLT.ProductDescription, SalesLT.ProductModel and SalesLT.ProductModelProductDescription. Choose DirectQuery when asked, so the report can show the change after the write.

  2. Add the table and the input slicer. Put ProductModel Name and ProductModelProductDescription ProductModelID in a table. Add an Input slicer and give it a title, for example “Write a new product description”.

  3. Add a blank button and turn its action on. In Format button, expand Action, switch it On and set Type to Data function.

  4. Pick the function. Select the fx button next to Data function. The OneLake catalog opens. Select the function. The pane then shows its workspace, function set and function name as read-only details. If the function is not listed, make sure it returns a string.

  5. Map each parameter. For the description choose the input slicer from the dropdown. For the model id select fx, keep Format style on Field value, pick ProductModel ProductModelID and set Summarization to Maximum. To pass a single key from the report, a measure also works. From the button page:

    SelectedCustomerID = SELECTEDVALUE(Customer[CustomerID])
    

    A parameter with a default value in the function is optional: leave it unmapped and the default is used.

  6. Style the loading state. In Style, switch Apply settings to Loading and set the button text, for example “Submitting”. Data function buttons have a Spinner icon for this state by default.

  7. Choose what happens after the call. In Format button, Action, the Auto clear toggle empties the slicer after submitting. The toggle “Refresh the report after a successful outcome” can be turned off if you do not want a refresh.

  8. Publish, then fix credentials if asked. Select Publish and open the report in the service. If you see “The data source is missing credentials and cannot be accessed”, open the semantic model, then File, Settings, Data source credentials, Edit credentials, choose the authentication method (for example OAuth2) and sign in.

  9. Run it. Select a product, type a description, press Tab or the arrow to submit, then select the button. Success shows “The action on your report was submitted successfully” and the table refreshes. A failure shows “Something went wrong”; select View details.

Copy this prompt

Use this when a report button must pass a different set of values to a Fabric function. Paste the prompt into your assistant’s chat with the parameters and the slicers, fields or measures you have. Ask for a mapping you can configure in Power BI and a way to diagnose failures.

My Power BI data function button calls the user data function <function name>.
Parameters: <name: type, ...>. The report has <slicers, tables, measures>.
Tell me, for each parameter, which report element should supply it and how to
configure it (slicer, field with summarization, or measure). Then list what
would make the button stay disabled, not list my function, or end with
"Something went wrong", in the order I should check them.

Check that the answer starts with the function’s return type and with permissions, and does not claim you can trigger the action in Desktop.

Limits

  • Only users authorised to run the function can use the button. Everyone else gets “Something went wrong”.
  • The function must return a str.
  • In Power BI Desktop you cannot trigger the action until the report is published.
  • A button or list slicer used as an input must be linked to a data field. Remove its visual interactions if you want it to act only as an input control.
  • The button does not rebind after deployment to another workspace. Update it by hand.
  • The refresh after the call depends on the storage mode and on the Refresh toggle.

Sources

Author

Rodrigo Lombana Reina, data engineer. Personal opinions. Checked against the documentation on 2026-11-29.

Questions

How do I add a data function button in Power BI?

Add a button, open Format button, expand Action, turn it on and set Type to Data function. Select the fx button next to Data function, pick the function in the OneLake catalog, then map each parameter to a slicer, a data field or a measure. Microsoft documents this in Power BI Desktop and the Power BI service.

Why can I not see my function in the data function picker?

Most likely because it does not return a string. Both Microsoft's tutorial and the button page tell you to check that the function returns a str when the function is missing. Fix the return type in the user data function, publish it again, and reopen the picker from the button's Action settings.

Can I test the button in Power BI Desktop?

You can set it up, and the button changes style when its parameters have values, but you cannot trigger the action until the report is published. Microsoft's tutorial suggests publishing to the Power BI service and testing there, because that shows the most accurate experience for the people who will use it.

What can supply a function's input?

A button, list or input slicer, a data field or a measure. A button or list slicer must be linked to a data field. An input slicer can be left unlinked, which is how you take free text. To pass one key such as a customer id, Microsoft suggests a measure using SELECTEDVALUE.

What does the error The data source is missing credentials mean?

The published semantic model has no stored credentials for its source. Open the semantic model, select File then Settings, expand Data source credentials, select Edit credentials, choose the authentication method, for example OAuth2, and sign in. Microsoft's tutorial lists exactly these steps for the first time you open the published report.

Why does the button show Something went wrong?

Select View details to read the reason. Microsoft lists four common causes: input that fails the function's validation rules, a timeout, a wrong button or parameter setup, and a user who is not allowed to run the function. A message you wrote with fn.UserThrownError appears in the details.

Can a parameter be optional?

Yes. A parameter that has a default value in the user data function is optional in the report. Leave it unmapped and the default is used, or map it without forcing the reader to enter anything. An input slicer shows the default as its placeholder. Microsoft lists optional parameters and default values as generally available since May 2026.

What happens to the button when I deploy the report to another workspace?

It keeps pointing at the original function. The button stores a fixed workspace, function set and data function, and deployment pipelines do not rebind it, even if a function with the same name exists in the target workspace. After deploying, open the button's Action settings in the target report and select the new function.

Portrait of Rodrigo Lombana Reina

Rodrigo Lombana Reina, data engineer. Data problems solved, step by step.

About Rodrigo · The opinions and texts on this site are my own.

My LinkedIn profile