Last week, a friend asked me why he could no longer create functioning SVG graphics from Chat GPT that he could use in Power BI. This surprised me a bit. I then entered a query for a graphic there, had the graphic output as an SVG, and then inserted it into Power BI. Unfortunately, this didn’t work. The problem was relatively simple; in the end, the following function was used: ENCODEURL
However, this doesn’t exist in Power BI, only in Excel. Personally, I think creating SVG graphics for Power BI is great; I also use this for icons, which I then use for graphics in Visio.
Here is a sample query for Chat GPT that returns such an SVG graphic, which you can then insert as a measure within Power BI.
Create an SVG icon showing a manager entering data. Also provide the SVG code that I can use within Power BI as a measure in a table. Please do not use ENCODEURL.
The following result is then returned:
Icon_Manager_DataEntry =
VAR stroke = "#2F3B44"
VAR blue = "#3A8DFF"
VAR svg =
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 128 128' role='img' aria-label='Manager enters data'>
<g fill='none' stroke='" & stroke & "' stroke-width='6' stroke-linecap='round' stroke-linejoin='round'>
<circle cx='36' cy='28' r='12'/>
<path d='M18 52c6-8 12-12 18-12s12 4 18 12v20H18V52z'/>
</g>
<path d='M36 40l4 8-4 8-4-8z' fill='" & blue & "'/>
<rect x='72' y='20' width='44' height='44' rx='6' fill='none' stroke='" & stroke & "' stroke-width='6'/>
<rect x='72' y='20' width='44' height='12' rx='6' fill='" & blue & "'/>
<g stroke='" & stroke & "' stroke-width='6' stroke-linecap='round'>
<line x1='72' y1='44' x2='116' y2='44'/>
<line x1='72' y1='60' x2='116' y2='60'/>
<line x1='88' y1='44' x2='88' y2='64'/>
<line x1='104' y1='44' x2='104' y2='64'/>
</g>
<line x1='50' y1='32' x2='66' y2='32' stroke='" & blue & "' stroke-width='6' stroke-linecap='round'/>
<polygon points='70,32 62,28 62,36' fill='" & blue & "'/>
</svg>"
VAR svg_no_crlf = SUBSTITUTE(SUBSTITUTE(svg, UNICHAR(10), ""), UNICHAR(13), "")
VAR svg_hash_ok = SUBSTITUTE(svg_no_crlf, "#", "%23") -- mask hex color hashes
VAR svg_sp_ok = SUBSTITUTE(svg_hash_ok, " ", "%20") -- (optional) mask spaces
RETURN "data:image/svg+xml;utf8," & svg_sp_ok

The returned code can then be inserted into Power BI:

I gave a further description of this in the following blog entry: