Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
LYorkToenniges
Helper II
Helper II

Refresh Webpage with button in Dashboard

I am currently in need of the correct code for creating a button that will refresh the page of the dashboard when clicked.  I have attempted to use a measure assigned to the button:

 

reload = "<button onClick=""window.location.reload();"">Refresh Page</button>"
as well as:
reload = "onClick""windows.location.reload();"""
 
I have little to no experience with HTML (obiviously) so making heads or tails of tutorials has been a problem.  Yes I know power automate can refresh datasets, it doesn't work for my use.  I need DAX equations that are using random number generation to regenerate and refresh seems to be the only way it works.
I need my user to be able to click a button and have the card visual displaying text to regerate a new response.  I feel programming an HTML button is the most practical way to do this, but am open to other suggestions. 
1 ACCEPTED SOLUTION
grazitti_sapna
Super User
Super User

Hi @LYorkToenniges,

In Power BI, HTML code like <button> or JavaScript (e.g., window.location.reload()😉 cannot be directly embedded or executed. Power BI does not support interactive scripting within visuals or buttons because it prioritizes security and sandboxing of reports.

However, there is an alternative solution to achieve the functionality of refreshing visuals or generating new responses:

Alternative Approach: Simulate Refresh with a Dynamic Visual
Instead of trying to program a refresh button using HTML/JavaScript, you can use measures with randomization and toggle slicers/buttons in Power BI. Here's how you can implement this:

Steps to Create a "Refresh" Effect:

  1. Create a Random Measure: Use a DAX measure that generates a random value each time the visual is refreshed or recalculated.
    • RandomValue = RAND()
    • This measure will generate a new random number every time the report is recalculated (e.g., when filters or slicers are changed).
  2. Add a Dummy Toggle for Refresh: Create a dummy table for a toggle button or slicer.

     

    • Go to Enter Data in Power BI.

    • Create a table called RefreshToggle with a single column and two rows:

      • Refresh
        On
        Off
  3. Use the Toggle to Trigger Recalculation: Add the Refresh column from the RefreshToggle table as a slicer or a button on your report. When the user toggles the slicer (e.g., switches between "On" and "Off"), it forces the report visuals to refresh and recompute the RandomValue measure.
  4. Display the Dynamic Value: Use the RandomValue measure in a card or visual to display dynamic responses. The value will update whenever the slicer state is toggled.

Option: Power Automate Button for Refresh
If you need a broader refresh (e.g., refreshing datasets or visuals), you can integrate Power Automate with a Power BI button:

  1. Add a Power Automate visual from the Power BI visuals pane.
  2. Create a Power Automate flow triggered by the button that refreshes the dataset or triggers the desired action.

Why HTML or JavaScript Won't Work:
Power BI visuals operate in a sandboxed environment that doesn't allow custom HTML or JavaScript for security and compatibility reasons. This is why embedding code like window.location.reload() will not work.

Using the randomization technique with slicers or Power Automate provides a secure and Power BI-native approach to achieve your goal.

I hope the provided solution works for you

If I have resolved your question, please consider marking my post as a solution. Thank you!
A kudos is always appreciated—it helps acknowledge the effort and keeps the community thriving.

View solution in original post

2 REPLIES 2
LYorkToenniges
Helper II
Helper II

Thank you so much for the comprehensive reply!  I will definitely use the slicer technique.  Sadly the power automate refresh dataset doesn't trigger a refresh of visuals so I wasn't working, hence the attempt at HTML.  

grazitti_sapna
Super User
Super User

Hi @LYorkToenniges,

In Power BI, HTML code like <button> or JavaScript (e.g., window.location.reload()😉 cannot be directly embedded or executed. Power BI does not support interactive scripting within visuals or buttons because it prioritizes security and sandboxing of reports.

However, there is an alternative solution to achieve the functionality of refreshing visuals or generating new responses:

Alternative Approach: Simulate Refresh with a Dynamic Visual
Instead of trying to program a refresh button using HTML/JavaScript, you can use measures with randomization and toggle slicers/buttons in Power BI. Here's how you can implement this:

Steps to Create a "Refresh" Effect:

  1. Create a Random Measure: Use a DAX measure that generates a random value each time the visual is refreshed or recalculated.
    • RandomValue = RAND()
    • This measure will generate a new random number every time the report is recalculated (e.g., when filters or slicers are changed).
  2. Add a Dummy Toggle for Refresh: Create a dummy table for a toggle button or slicer.

     

    • Go to Enter Data in Power BI.

    • Create a table called RefreshToggle with a single column and two rows:

      • Refresh
        On
        Off
  3. Use the Toggle to Trigger Recalculation: Add the Refresh column from the RefreshToggle table as a slicer or a button on your report. When the user toggles the slicer (e.g., switches between "On" and "Off"), it forces the report visuals to refresh and recompute the RandomValue measure.
  4. Display the Dynamic Value: Use the RandomValue measure in a card or visual to display dynamic responses. The value will update whenever the slicer state is toggled.

Option: Power Automate Button for Refresh
If you need a broader refresh (e.g., refreshing datasets or visuals), you can integrate Power Automate with a Power BI button:

  1. Add a Power Automate visual from the Power BI visuals pane.
  2. Create a Power Automate flow triggered by the button that refreshes the dataset or triggers the desired action.

Why HTML or JavaScript Won't Work:
Power BI visuals operate in a sandboxed environment that doesn't allow custom HTML or JavaScript for security and compatibility reasons. This is why embedding code like window.location.reload() will not work.

Using the randomization technique with slicers or Power Automate provides a secure and Power BI-native approach to achieve your goal.

I hope the provided solution works for you

If I have resolved your question, please consider marking my post as a solution. Thank you!
A kudos is always appreciated—it helps acknowledge the effort and keeps the community thriving.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.