Forum Discussion

Th1sGuy's avatar
Th1sGuy
Frequent Visitor
3 months ago
Solved

Dynamic images based on selections

Hi all,

I know there's a few questions related to this swimming around, but haven't come across my specific issue yet somewhat surprisingly.

I need to show different, color-coded images depending on programs that are selected. I initially achieved this by using a transparent version of the base image and applying conditional shading, but I'm not happy with the results. Plus, our comms dept went through the trouble of making separate icons for each status, so I'd like to use them. Here's what I created based on shading:


However, we have separate green, orange, and blue versions of each icon I'd like to use instead for a cleaner look. All icons are publicly accessible via URL. I'm assuming I'll need to use some sort of dax measure (leaning towards Switch), but haven't quite figured it out yet. If you need any further information, please let me know!

Any guidance would be greatly appreciated.

Thank you!

  • Hi   Th1sGuy 

    I'm sure there must be plenty of different ways to achieve this, but the first thing that comes to my mind is using the new image SVG option (https://www.youtube.com/watch?v=BvKbKQHVNi0&t=125s).

    However, you will need to convert or generate your images in SVG format.

    Once you have the SVG image code, it's pretty easy , just create measures (you can use any AI tool to convert your SVG image code into a measure), like in the attached sample, and use a slicer to switch between the images.

     

    I have attached the sample I created for your reference.

     

     

6 Replies

  • The cleanest way is to drive this from a column, since "Image URL" is a column level data category in Power BI.

     

    Add a small lookup table in Power Query with two columns, status and icon URL, and relate it to your existing program/status field. Select the URL column, go to Column tools and set Data category to Image URL. Drop the column into a Card visual (or table/matrix), and the slicer will swap the icon automatically as the selection changes.

     

    If you prefer SWITCH in a measure, that works too, but you have to render it through the newer Image visual, since measures cannot carry the Image URL category.

     

    If this works for you, kindly mark it as the solution and give a thumbs up.

     

    Best,

    Shai Karmani

  • Hi Th1sGuy

    Approach is to handle this to return image URLs dynamically through measure

    Can you try this approach

    Dynamic Icon =

    VAR Program = SELECTEDVALUE('Table'[Program])

    VAR Status = SELECTEDVALUE('Table'[Status])

    RETURN

    SWITCH(TRUE(),

    Program = "Wind" && Status = "Green", "https://.../wind_green.png",

        Program = "Wind" && Status = "Orange", "https://.../wind_orange.png",

        Program = "Wind" && Status = "Blue", "https://.../wind_blue.png",

        Program = "Solar" && Status = "Green", "https://.../solar_green.png",

        Program = "Solar" && Status = "Orange", "https://.../solar_orange.png",

        Program = "Solar" && Status = "Blue", "https://.../solar_blue.png", BLANK())

    • Th1sGuy's avatar
      Th1sGuy
      Frequent Visitor

      Tried getting this to work, but I'm guessing I'm doing something wrong. Would it be helpful to share the PBIX?

  • Hi   Th1sGuy 

    I'm sure there must be plenty of different ways to achieve this, but the first thing that comes to my mind is using the new image SVG option (https://www.youtube.com/watch?v=BvKbKQHVNi0&t=125s).

    However, you will need to convert or generate your images in SVG format.

    Once you have the SVG image code, it's pretty easy , just create measures (you can use any AI tool to convert your SVG image code into a measure), like in the attached sample, and use a slicer to switch between the images.

     

    I have attached the sample I created for your reference.

     

     

  • Hi Th1sGuy

    Thank you for reaching out to the Microsoft Fabric Community Forum. Also, thanks to kushanNakrishnakanth240Shai_Karmani,  for those inputs on this thread.

    Has your issue been resolved? If the response provided by the community member kushanNakrishnakanth240Shai_Karmani, addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.

    Hope this helps clarify things and let me know what you find after giving these steps a try happy to help you investigate this further.

    Thank you for using the Microsoft Community Forum.

    • v-kpoloju-msft's avatar
      v-kpoloju-msft
      Community Support

      Hi Th1sGuy

      Just wanted to follow up. If the shared guidance worked for you, that’s wonderful hopefully it also helps others looking for similar answers. If there’s anything else you'd like to explore or clarify, don’t hesitate to reach out.

      Thank you.