Power BI has several options to display images in a report or dashboard but they mostly require that the image is a url to a publicly accessible website. What I'll show you in this post is a way to take images stored in a database and bind them to a table visualization. This will work with lots of visuals that display images. My use case was to display chart images generated from R using SQL Server's Machine Learning Server
@Meagan Longoria recently introduced me a great article from @SQLJason Embedding Images in Power BI using Base64. This gave me all the information I needed to look at solution to bind image data stored in a SQL Server table.
Definitely read SqlJason's article, paying close attention to limitations etc. This solution is meant for relatively small images you would show in a report. If you use it for large images it will likely fail. Reduce the resolution in those cases.
Getting images into SQL Server
Go to your favorite SQL Server and create a table and insert some images. Here's my sample code to give you one way you can get images into a database table
--CREATE Table Logo --( -- LogoId int, -- LogoName varchar(255), -- LogoImage image --) INSERT INTO dbo.Logo ( LogoId, LogoName, LogoImage ) SELECT 1,'Power BI', * FROM OPENROWSET ( BULK 'C:\Users\me\Desktop\LogoDemo\powerbi.png',SINGLE_CLOB) as ImageFile INSERT INTO dbo.Logo ( LogoId, LogoName, LogoImage ) SELECT 2,'Azure', * FROM OPENROWSET ( BULK 'C:\Users\me\Desktop\LogoDemo\azure.png',SINGLE_CLOB) as ImageFile INSERT INTO dbo.Logo ( LogoId, LogoName, LogoImage ) SELECT 3,'Microsoft', * FROM OPENROWSET ( BULK 'C:\Users\me\Desktop\LogoDemo\microsoft.png',SINGLE_CLOB) as ImageFile
Get the image data using Power BI Desktop
Now that you have some images in a SQL table, switch over to Power BI Desktop and get the data.
(In Desktop: Get Data, SQL Server, Login to your SQL Server, and pick your table that stores images.
Change the binary column to Text
Now create a custom column and append a URI to tell Power BI these are png images. If using jpeg use jpeg instead of png.
Close & Apply the data.
This is an important step. In the Modeling tab, change the image column ([Logo]) to a Data Category of Image URL.
Now you can use a visuals, like a table, and display your images that came from a SQL Server vs. having to find a way to store images on a public internet site.
I hope this works for you like it did for me.
Solved! Go to Solution.
I've found that the maximum length a string can have to be processed by Power BI is 32766 characters.
So once you've converted your image to a Base64 string, if the length of the string is greater than this then it will crop the image.