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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
kkk93
Frequent Visitor

How to change value of a slicer programmatically to all the values for that variable

I have a dashboard created and have added a slicer in there. Slicer is the user id column from user table. I want to capture a screenshot of the dashboard for all the user id's. Can it be automated? If so please guide me in the right direction with some documentation around it. 

Thank you 

1 ACCEPTED SOLUTION
DataNinja777
Super User
Super User

Hi @kkk93 ,

 

You can automate changing a slicer’s value to "All" programmatically in Power BI using Power Automate, Power BI REST API, Bookmarks, DAX Measures, or Python/R scripting.

One approach is to use Power Automate in combination with the Power BI REST API. Power Automate can loop through all User IDs and take screenshots programmatically. You can first create a flow that retrieves the list of all User IDs, then use the Power Automate UI Flows to simulate selecting each User ID in the slicer. After selecting the ID, the flow can call the Power BI REST API to export the report page as an image or PDF and save it. The Power BI REST API provides an export-to function that allows exporting a report in various formats, including PNG and PDF, which is useful for automated screenshot capturing. The REST API documentation provides details on how to structure these calls:
Power BI REST API - Export Reports.

Another way to achieve this is by using a Power BI Bookmark. To create a bookmark, first select All Users in the slicer, then go to the View tab, open Bookmarks, and add a new bookmark. Make sure to enable the Data option so that the slicer selection is captured. Once this is set up, you can use Power Automate to apply the bookmark programmatically before taking a screenshot.

A DAX-based method can also be used to dynamically control the slicer’s behavior. You can create a measure that checks whether a selection has been applied and displays either the selected User IDs or the text "All Users."

 

 

SelectedUsers = 
IF(
    ISFILTERED(UserTable[UserID]), 
    CONCATENATEX(VALUES(UserTable[UserID]), UserTable[UserID], ", "),
    "All Users"
)

 

 

For users who want full automation at the browser level, Python or R scripting can be used to automate the interaction with Power BI Service. Using Python with Selenium, for example, you can simulate UI interactions where the script selects each User ID in the slicer, waits for the dashboard to update, and takes a screenshot.

 

 

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://your-powerbi-report-url")
driver.save_screenshot("screenshot.png")
driver.quit()

 

 

Each of these methods offers different levels of automation depending on whether you are working with Power BI Desktop or Power BI Service. Power Automate with REST API is best for fully automated screenshot exports, while Bookmarks and DAX provide easy in-report solutions. For more advanced UI automation, Python and Selenium can be used to interact with Power BI Service.

 

Best regards

View solution in original post

1 REPLY 1
DataNinja777
Super User
Super User

Hi @kkk93 ,

 

You can automate changing a slicer’s value to "All" programmatically in Power BI using Power Automate, Power BI REST API, Bookmarks, DAX Measures, or Python/R scripting.

One approach is to use Power Automate in combination with the Power BI REST API. Power Automate can loop through all User IDs and take screenshots programmatically. You can first create a flow that retrieves the list of all User IDs, then use the Power Automate UI Flows to simulate selecting each User ID in the slicer. After selecting the ID, the flow can call the Power BI REST API to export the report page as an image or PDF and save it. The Power BI REST API provides an export-to function that allows exporting a report in various formats, including PNG and PDF, which is useful for automated screenshot capturing. The REST API documentation provides details on how to structure these calls:
Power BI REST API - Export Reports.

Another way to achieve this is by using a Power BI Bookmark. To create a bookmark, first select All Users in the slicer, then go to the View tab, open Bookmarks, and add a new bookmark. Make sure to enable the Data option so that the slicer selection is captured. Once this is set up, you can use Power Automate to apply the bookmark programmatically before taking a screenshot.

A DAX-based method can also be used to dynamically control the slicer’s behavior. You can create a measure that checks whether a selection has been applied and displays either the selected User IDs or the text "All Users."

 

 

SelectedUsers = 
IF(
    ISFILTERED(UserTable[UserID]), 
    CONCATENATEX(VALUES(UserTable[UserID]), UserTable[UserID], ", "),
    "All Users"
)

 

 

For users who want full automation at the browser level, Python or R scripting can be used to automate the interaction with Power BI Service. Using Python with Selenium, for example, you can simulate UI interactions where the script selects each User ID in the slicer, waits for the dashboard to update, and takes a screenshot.

 

 

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://your-powerbi-report-url")
driver.save_screenshot("screenshot.png")
driver.quit()

 

 

Each of these methods offers different levels of automation depending on whether you are working with Power BI Desktop or Power BI Service. Power Automate with REST API is best for fully automated screenshot exports, while Bookmarks and DAX provide easy in-report solutions. For more advanced UI automation, Python and Selenium can be used to interact with Power BI Service.

 

Best regards

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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