Forum Discussion

Martin_D's avatar
Martin_D
Solution Sage
1 year ago
Solved

SVG image doesn't load bitmap URLs

Hi,


I've created a measure that returns SVG code that loads bitmap images from a web-server to include them in the SVG image. I know the SVG code is correct, because it shows the correct image in the "HTML Content" custom visual. But when using Power BI built in visuals, it doesn't load the images. They appear broken.

Does anyone know a way to fix this, e.g., by storing the files in a specific, allowed location, e.g., a SharePoint in the same tenant, crafting a specific URL or something? Embedding the base64 encoded bitmap images into the measure wasn't an option because the string length exceeds the buffer length so it doesn't work.

This is the measure code:

"data:image/svg+xml;utf8," &
"<svg width='388' height='325' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
    <image x='0' y='240' width='38' height='325' xlink:href='https://github.com/MartinBubenheimer/powerbi-solutions/blob/main/svg/assets/Stick.png?raw=true' />
    <image x='70' y='210' width='38' height='325' xlink:href='https://github.com/MartinBubenheimer/powerbi-solutions/blob/main/svg/assets/Stick.png?raw=true' />
    <image x='140' y='140' width='38' height='325' xlink:href='https://github.com/MartinBubenheimer/powerbi-solutions/blob/main/svg/assets/Stick.png?raw=true' />
    <image x='210' y='90' width='38' height='325' xlink:href='https://github.com/MartinBubenheimer/powerbi-solutions/blob/main/svg/assets/Stick.png?raw=true' />
    <image x='280' y='110' width='38' height='325' xlink:href='https://github.com/MartinBubenheimer/powerbi-solutions/blob/main/svg/assets/Stick.png?raw=true' />
    <image x='350' y='4' width='38' height='321' xlink:href='https://github.com/MartinBubenheimer/powerbi-solutions/blob/main/svg/assets/Cracker.png?raw=true' />
</svg>"

 

And this is the result in a new card visual:

It shows four broken images, that's not your browser πŸ˜‰

Kind regards,
Martin

5 Replies

  • Inline the images as Base64 strings. Split the strings into pieces smaller than 32K and then put them back together in the measure.

     

    https://blog.crossjoin.co.uk/2019/05/19/storing-large-images-in-power-bi-datasets/

     

    You will need to use a link to the actual raw file.

     

     

    You can also try to inline these into the SVG

     

    Does SVG support embedding of bitmap images? - Stack Overflow

     

    But that may also not work with the built-in visuals.

    • Martin_D's avatar
      Martin_D
      Solution Sage

      Hi lbendlin ,


      Thank you for looking into this issue. I should have mentioned that my semantic model uses calculation groups. All you described works in models without calculation groups, but as mentioned in the comments of your referenced article, your solution is not compatible with calculation groups in the same semantic model (same as default auto aggregations, but as Microsoft users we tend to call such behaviour "feature", don't we? πŸ˜‰). Or, more precise, the original idea of Chris Webb was to overcome a limit of how much text you can load into one text field in the database, not to overcome a limit in DAX measures. With calculation groups in the same model, the text limit for a measure is the same as the text limit for a text field in the database, so it becomes obsolete in this case. See: Chris Webb's BI Blog: Storing Large Images In Power BI Datasets

       

      That's why I was rather following the URL linked image approach rather than the URL embedded image approach. Any idea whether this could work under specific constraints or circumstances?

      Kind regards,
      Martin

      • Martin_D's avatar
        Martin_D
        Solution Sage

        Update: Power BI can access the image files and accepts them if I create a measure only containing the URL of one image. Then the image appears, e.g., in a Matrix visual. It only does not appear when the link is used inside of the SVG code.

         

        When embedding an image (that is small enough) in the SVG code, it also shows up correctly.

         

        So the following works:

         

        • Loading an image from a URL link into a standard visual
        • Showing bitmap images as part of DAX generated SVG code, as long as the image is embedded
        • Showing the SVG image including bitmap images that are loaded from URL links inside of the SVG code by using the "HTML Content" custom visual

        Now what is missing is the combination:

         

        • Loading an image from a URL link within DAX generated SVG code and showing it in Power BI standard visuals (new card visual, matrix, table)

        Without further ado such images appear as broken.

  • Martin_D's avatar
    Martin_D
    Solution Sage

    I think it's a feature πŸ˜‰ As long as nobody locks me out of the HTML Content custom visual I'll try to stick to this workaround.