Power BI – Using OneDrive to Embed and Host Images for Power BI
I was recently on the Power BI Forums and I have seen a question before around where and how to host images that can be used within Power BI.
I am going to show this with the example below.
- I am going to show you how to upload images to OneDrive, which can host your images for free.
- Then I will show you how to get the Embed Codes
- And finally put it all together in a Power BI Desktop file, so when it is viewed in either Power BI Desktop or the Power BI Service, I am then able to view the images.
Uploading Images to OneDrive
In the steps below I will give you the links where you can sign up and get 5GB free storage (which should be sufficient for hosting images) and then show you how to upload your images to OneDrive.
Signing up to use OneDrive’s free 5GB Storage
- You can access the following link: OneDrive Pricing Plans, and I could see below there are the different pricing options as well as the OneDrive Basic 5GB
- I then clicked on the Sign Up and completed the steps in order to get access to my OneDrive
Uploading my Images into OneDrive
- Next what I did was to upload my images that I had into OneDrive by following the steps below.
- NOTE: I had already got the images that I needed saved on my local PC. So, all that I had to do was to simply upload them into my OneDrive location.
I went into OneDrive and created a separate folder, which makes it easier for me to know what images are stored where.
I then uploaded my images into this folder.
- Now that I have my images uploaded to OneDrive in the next steps I demonstrate how I got the Embed Codes.
Getting the Embed Codes from OneDrive
There is a difference in OneDrive between Sharing a File and Embedding a file.
- When you Share a file with a link what happens is that the person who clicks on the link will be viewing the file from their browser in the OneDrive Location.
- Whilst when you embed the file also with a link, this is then rendering the file from OneDrive into an application or location.
For the purpose of this blog post I wanted to Embed the file, and get the link.
- I went into OneDrive and to the location of where I have my images saved.
I then right clicked on my first image called “bluebells.jpg” and selected Embed
On the left-hand side, this then brought up the Embed “bluebells” in a blog or web page dialog
- I then clicked on Generate
Once it was done I was then presented with the URL to embed image
What I then did was to copy the URL code into Excel and pasted it into a table which had my Image Names and Embed Codes.
- NOTE: This is so that I can easily import this into Power BI Desktop later.
- Also when I generated the embed code above I did not put a tick in the box for “Include HTML tags” because I just wanted the link to the file.
- I then did this for all my 5 images.
This is what my spreadsheet looked like once completed.
- I then saved my spreadsheet so that in the next steps I could import it into Power BI.
Importing spreadsheet data into Power BI & configuring columns data types
In the next steps, I will show how I imported the spreadsheet and then configured the column data type so that it can be seen as an image URL.
- I opened up Power BI Desktop and went into the Query Editor.
I then clicked on New Source and selected Excel
I then selected my table that I had created earlier and clicked Ok
- Once I could see the table with my data in the Query Editor I clicked on Close and Apply
Now back in Power BI Desktop I went to my table called “Table5” and went to my column called URL.
- I clicked on the column, and to make sure that it was selected I ensured that I had the thin yellow bar around the column called “URL”
Then in the ribbon I clicked on Modeling.
- I then went under the Properties section and changed the Data Category from Uncategorized to Image URL
Testing that the images will render
Now finally I could test to make sure that the images will render from OneDrive in both Power BI Desktop and the Power BI Service.
- I created a table and put in the Image Name and URL.
As you can see below it is rendering the file from OneDrive
Now if I had used the Share link from OneDrive this is what it looks like due to not being able to render the image files from OneDrive correctly.
And here is what it looks like once upload to the Power BI Service.
As I have shown in the steps above is how to use OneDrive to host my image files, get the embed codes and then use them within Power BI Desktop so that they can be successfully rendered for reports.
If there are any questions or comments please leave them in the section below.