Converting HTTPs link images/icons to Base 64 in Power BI

If you have a column of images/icons in https links format like below:

Then you can convert it to base 64 URL format, which is the acceptable format by the xViz Performance Flow visual (as it is certified):

Steps to be followed in Transform Editor/Power Query:

Step 1: Create a Custom Function in your Power BI report -> Transform Data:

  1. Home → New Source → Blank Query

  1. Change the name of the query to Query1 to ImgtoBase64Url and Click on Advanced Editor

  1. Paste the below code and Click on Done:

    Source = (ImageUrl as text) as text =>
    BinaryContent = Web.Contents(ImageUrl),
    Base64 = "data:image/jpeg;base64, " & Binary.ToText(BinaryContent, BinaryEncoding.Base64)

Note: The prefix of "data:image/jpeg;base64, " must be adjusted as per the image extension, i.e. replace the "jpeg" with the extension of the image that you are using (eg: png, etc.)

Step 2: Invoke the custom function in the data:

  1. Add Column → Invoke Custom Function

  1. Add the following details in the popup:

    1. Provide a name for the new column

    2. Select the function query name “ImgtoBase64Url

    3. Select the column with Images URL

Result: This will result in a new column named "Image" which will contain the Base 64 URLs. Use this column in the xViz Performance Flow visual.

Here is an example report file:

If the images you are referring are of high resolution which results in over 33,000 characters in base 64 format, then you might see only partial image rendering because of the character limit in Power BI. Check out this page for the solution - Handling long Base 64 URLs in Power BI

Last updated