Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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:
Solved! Go to Solution.
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:
RandomValue = RAND()
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
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:
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.
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.
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:
RandomValue = RAND()
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
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:
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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
78 | |
76 | |
58 | |
35 | |
33 |
User | Count |
---|---|
100 | |
60 | |
56 | |
46 | |
41 |