Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
10.5k views
in Power BI by 13 15 24

I am using Power BI RS, and I have a request to change the flag image based on the selected country list in a slicer. like below screen

change image based on slicer in Power BI

In power BI the native image control only used to import static image to the project 

Change image dynamically based on selection in Power BI

So, How we can change image based on slicer in Power BI?


2 Answers

2 like 0 dislike
by 159 200 385
selected by
 
Best answer

How to Change flag image based on the selected country value in a slicer in Power BI?

In the Power BI desktop, you can't use image control to change the image based on the slicer, it's just used to show a static image.
So, to can show an image based on your slicer selection, you should instead use one of the below visuals:

  1. Table Visual.
  2. Multi-Card Visual.

visualization in Power BI

You can download the PBIX file at Power BI change flag image based on the selected country


Show Image Based on Slicer in Power BI using Table.

Steps

  • Consider, you have a country table with its corresponding flag image URL as shown below.
    flags table in Power BI
  • At the Report view, in Fields, select your flag field that holds the image URL.
    image column in Power BI
  • In the above ribbon, Click on the "Modeling" tab, and in the properties section, change the Data Category to Image URL.
    Data Category Image URL in Power BI
  • Now, drag a table from the Visualizations section.
  • Add the flag field in Table values.
    show image in a table in Power BI
  • Remove the Table header as mentioned at Remove the table column header in Power BI
  • In the Grid, change the Image Height as you prefer.
    change image size in a table in Power BI
  • In the field formatting, set the Alignment to center.
    align field in a table in Power BI
  • Now, add a new slicer, and add the country field in the field section.
    create a slicer in Power BI
  • In the selection control, enable single selection.
    set the slicer to single selection in power bi
  • Show the slicer as a dropdown list.
    show slicer as a dropdown list in Power BI
  • Try to change the country value in the slicer now.
  • Great, the flag image is changed based on the selected value as shown below:

Output

Show Image Based on Slicer in Power BI using Table.


Show Image Based on Slicer in Power BI using Multi-Card.

You can also use Multi-Card visual to show an image based on slicer in Power BI. but using this visual, you will NOT be able to change the image height or set its alignment to right or center. In this case, from the beginning, you should use a proper image size or use the above table method to control such properties.

Steps

  • Add a Multi-Card visual.
  • In the fields section, add the flag field.
  • Turn off the show bar, and category label options.
  • Use the same slicer creation steps that have been mentioned in the above method

Output
Show Image Based on Slicer in Power BI using Multi-Card


Download the PBIX file

0 like 0 dislike
by 13 15 24

As I mentioned before the native control will not fit the requirement, So I found a workaround solution to apply it.

Steps:

  • Open the MarketPlace from the top ribbon and search for control with name "Simple Image" and add It to power bi
    Image Control

  • After that, we will add the "Simple Image" control to the page and assign the Flag URL field to the "Image URL" property.
    Control in page

  • Now it should work probably
If you don’t ask, the answer is always NO!
...