Handling long Base 64 URLs in Power BI

If the images are displaying partially in Power BI with the Base 64 URLs, then the reason is the character limit in Power BI. The maximum length of a text value that the Power Query engine can load into a single cell in a table in a dataset is 32,766 characters – any more than that and the text will be silently truncated.

Check the length of characters of the Base64 URL in Transform Editor/Power Query

To understand what the length of the Base 64 URLs for your images is, please follow the below steps:

  1. Select the Base 64 column of the image

  2. Add column → Extract → Length

  1. You will now be able to see the length of the Characters of all the Base64 URLs

Steps to handle long Base 64 URLs to display the full images

Step 1: Data Type of the Base 64 URL column

Ensure that the data type of the Base 64 URL column must be "Text"

Step 2: Transformation steps in Advanced Editor

Open the Advanced Editor of the same query for the next set of steps:

  1. Click on Advanced Editor

  1. Copy and paste the below code in the existing steps:

   // Creates Splitter function
   #"SplitTextFunction" = Splitter.SplitTextByRepeatedLengths(30000),
   // Converts table to list
   #"Input List" = Table.ToRows(LastStepName),
   //Function to convert binary images to multiple text values
   #"Convert 1 File" = (InputRow as list) =>
        BinaryIn = InputRow{1},
        FileName = InputRow{0},
        BinaryText = Binary.ToText(BinaryIn, BinaryEncoding.Base64),
        SplitUpText = SplitTextFunction(InputRow{1}),
        AddFileName = List.Transform(SplitUpText, each {FileName,_})
   // Loops over all images and calls the above function
   #"Convert All File" = List.Transform(#"Input List", each #"Convert 1 File"(_)),
   // Combines lists together
   #"Combine the Lists" = List.Combine(#"Convert All File"),
   // Converts results to table
   #"Convert to Table" = #table(type table[Name=text,Base64 Img=text],#"Combine the Lists"),
   // Adds index column to output table 
   #"Added Index" = Table.AddIndexColumn(#"Convert to Table", "Index", 1, 1, Int64.Type)
    #"Added Index"

Note: Ensure to replace LastStepName with the name of the last step that you see in the Advanced Editor before pasting this code

The final query should look something like as shown below:

Step 3: Creating a DAX measure to group the Base64 URL to display the images

  1. Create the below DAX measure to display the images

Display Image = 
        Base64[Base64 Img],
  1. Add the DAX measure in the Performance Flow visual and display the images

Last updated