Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
hejszyszky
Helper II
Helper II

Bullet chart SVG

Hi,

I've been trying to create bullet charts within table with variables. It does not work and outputs "image" icon.  I bet that it is SVG code related problem, but since i am not an expert with it and i cant find solution to resolve this problem i would be pleased to get some help 🙂 Here is code below, thanks in advance!

 

Bullet = 

VAR vBackground = "%23ffffff"

VAR vBarColor = Switch(
    True(),
                [losspln] <= [targetpln], "%2339a964",
                [targetpln] = 0, "%23ffa160",
                [losspln] > [targetpln], "%23cd1319"
                )

VAR vActBarColor = "%23333333"
VAR vTargetBarColor = "%23888888"

// Base Text for drawing
 
VAR vBaseText = 
"data&colon;image/svg+xml;utf8, <svg width='100' height='100' version='1.1' xmlns='http://www.w3.org/2000/svg' style= 'background: " & vBackground & "'>
  <rect  x='0'       y='25'   rx='2' ry='2'   width='100'       height='50'   style='fill:" & vBarColor & ";stroke-width:0;fill-opacity:1' /> 
  <rect  x='0'       y='45'   rx='2' ry='2'   width=""#Actual"" height='10'   style='fill:" & vActBarColor & ";stroke-width:0;fill-opacity:1' />
  <rect  x=""#Budget"" y='30'   rx='2' ry='2'   width='6'         height='40'   style='fill:" & vTargetBarColor & ";stroke:black;stroke-width:0;fill-opacity:1;stroke-opacity:1' />
</svg>"

VAR vObjects = ALL(Resource[Resource Short])

VAR vMaxActual = MAXX( vObjects, [losspln] )
VAR vMaxGoal   = MAXX( vObjects, [targetpln] )

VAR vXAxisRangeBase = MAX( vMaxActual, vMaxGoal )

VAR vActual = INT( DIVIDE( [losspln], vXAxisRangeBase ) * 90 )
VAR vGoal   = INT( DIVIDE( [targetpln],  vXAxisRangeBase ) * 90 )

VAR vReturn = SUBSTITUTE( SUBSTITUTE( vBaseText, "#Actual", vActual ), "#Goal", vGoal )

RETURN IF( [losspln], vReturn, BLANK() )

 

 

1 ACCEPTED SOLUTION
KerKol
Impactful Individual
Impactful Individual

What does your svg code show when you change it to text and view in focus mode?

 

KerKol_1-1634352154506.png

 

You'll need to be careful your width and height values are properly escaped...

width=""#Actual""  will need to be something like... width="&"'"&"#Actual"&"'"&"

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
KerKol
Impactful Individual
Impactful Individual

What does your svg code show when you change it to text and view in focus mode?

 

KerKol_1-1634352154506.png

 

You'll need to be careful your width and height values are properly escaped...

width=""#Actual""  will need to be something like... width="&"'"&"#Actual"&"'"&"

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Yes, that obviously was a problem with apostrophes. Changed also ' to ""

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.