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.

Image 1: Images displaying partially in Power BI

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

Image 2: Extracting the length of every value for a column in Power Query
  1. You will now be able to see the length of the Characters of all the Base64 URLs

Image 3: Length of Base 64 URLs in Power Query

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"

Image 4: Data type as 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

Image 5: Advanced Editor option in Power Query
  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) =>
     let
        BinaryIn = InputRow{1},
        FileName = InputRow{0},
        BinaryText = Binary.ToText(BinaryIn, BinaryEncoding.Base64),
        SplitUpText = SplitTextFunction(InputRow{1}),
        AddFileName = List.Transform(SplitUpText, each {FileName,_})
     in
        AddFileName,
   // 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)
in
    #"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:

Image 6: Final query look

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 = 
   CONCATENATEX(
        'Base64', 
        Base64[Base64 Img],
        , 
        Base64[Index],
        ASC)
  1. Add the DAX measure in the Performance Flow visual and display the images

Image 7:High-resolution Images in xViz Performance Flow visual

Last updated