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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
planc7
Helper I
Helper I

Conditional Formatting: adding icon with field value option

Hi everyone,

 

I'm struggling to add custom icon in matrix with field value option.

 

I have created this measure expecting the icon appearing in the blue column but nothing happened.

 

What am I doing wrong?

 

planc7_1-1725627915545.png

planc7_0-1725628215737.png

 

 

 

The measure used is the following:

 

 

Test Date Gates Gantt = 

Var svgStart = "data&colon;image/svg+xml;utf8, <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'> <circle cx='50' cy='50' r='40' stroke='purple' stroke-width='4' fill='purple' />"
var svgFinish = "</svg>"

var res= 
IF(SELECTEDVALUE('Tracker Gates Home'[Date Type])="Actual/Planned" && MAX('Tracker Gates Home'[Week])="202312",
 svgStart & "<circle cx='50' cy='50' r='40'  stroke='#5D6E5A' stroke-width='4' fill='#5D6E5A' />" & svgFinish)
    

return res

 

 

 

Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @planc7 ,
Thanks for amitchandak reply.
After making sure that your filters are not incorrect, you can check to see if the Data Category of your measure is set to the Image URL format, so that the SVG format you are referencing will be recognized correctly. The following pbix file is an example of using the SVG format.

vheqmsft_0-1727068813009.png

 

Best regards,
Albert He


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @planc7 ,
Thanks for amitchandak reply.
After making sure that your filters are not incorrect, you can check to see if the Data Category of your measure is set to the Image URL format, so that the SVG format you are referencing will be recognized correctly. The following pbix file is an example of using the SVG format.

vheqmsft_0-1727068813009.png

 

Best regards,
Albert He


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

Thank you!

 

It seems working!

 

However, I think I have some problem in the SVG Code.

I downloaded this code from SVG Viewer but I'm not able to show image in PowerBi.

 

<svg fill="#000000" width="800px" height="800px" viewBox="-6.5 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg">
<title>bar</title>
<path d="M8.469-1.156h2.25v29.813h-2.25v-29.813z"></path>
</svg>

 

 

Is the following code right or am I doing something wrong?

 

Thank you again 🙂

 

 

SWITCH(
    TRUE(),
    SUM('Table'[Indicator]) >=0 && SUM('Table'[Indicator]) <=2 ,"data&colon;image/svg+xml;utf8, <svg fill='#000000' width='800px' height='800px' viewBox='-6.5 0 32 32' version='1.1' xmlns='http://www.w3.org/2000/svg'> <path d='M8.469-1.156h2.25v29.813h-2.25v-29.813z'></path></svg>"
)

 

Anonymous
Not applicable

Hi @planc7 ,
You can try this

Icon 2 = 
SWITCH(
    TRUE(),
    SUM('Table'[Indicator]) >=0 && SUM('Table'[Indicator]) <=2 ,"data&colon;image/svg+xml;utf8, <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' version='1.1' > <path d='M8.469-1.156h2.25v29.813h-2.25v-29.813z'></path></svg>",
    SUM('Table'[Indicator]) > 2 && SUM('Table'[Indicator]) <=3,"data&colon;image/svg+xml;utf8, <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'> <circle cx='50' cy='50' r='30' stroke='yellow' stroke-width='4' fill='yellow' /> </svg>",
    SUM('Table'[Indicator]) > 3,"data&colon;image/svg+xml;utf8, <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'> <circle cx='50' cy='50' r='20' stroke='green' stroke-width='4' fill='green' /> </svg>"
) 

Final output

vheqmsft_0-1727078586222.png

Best regards,
Albert He


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

It works only replacing

 

data&colon;image/svg+xml;utf8"

with

data -two points- image/svg+xml;utf8

 

this is anyway the result I need, thank you!!!!

 

Spoiler
PS: This form adds spontaneously colon into code ... This is the reason why I wrote literally two points 😅
amitchandak
Super User
Super User

@planc7 , you can use unichar item in a measure and use that in the display. you can color them with conditional formatting

 

https://exceleratorbi.com.au/conditional-formatting-using-icons-in-power-bi/
https://community.powerbi.com/t5/Desktop/FORMAT-icon-set-for-use-in-a-data-card/td-p/811692

https://exceleratorbi.com.au/dax-unichar-function-power-bi/

 

You can also consider dynamic format string https://youtu.be/qHALucET7N8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I've already tried replacing SVG code with Unichar character but nothing changed.

What i need to do is adding a vertical line in that matrix (without adding another field in the value section), and I was trying to reach this result thinking of some work around with icons.

 

The expected outcome should be the following:

a matrix gantt with a milestones (yes, I've already tried with custom visual gantt but they are not suitable for my use case)

planc7_0-1725630530680.png

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.