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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
DongdongYu
New Member

How to automate change shape's colors based on values?

I have a demand to show the system's available status. 

 

Here is the expected output below. 

DongdongYu_0-1727233980732.png

 

Due to some reasons, I must use 'shapes' to present the availability ( and seems this is the only way to do that ).  As you can see the blue & red circles above,  a green circle means good, and a red circle means something wrong.  

 

Right now, all these 'shapes' and color are changed manually.

 

But what I need is that the circles able to change its color automatically based on values from the database table. 

  1. if the values is 0, than the shapes color should be 'red'.
  2. if the values is 1, than the shapes color should be 'gree'.

May I know how to change the shape's color based on the values? Thanks. 

 

 

1 ACCEPTED SOLUTION

You can use create a measure that generates a SVG image of a circle. ease see sample pbix

Circle = 
VAR __RAND =
    ISODD ( SELECTEDVALUE ( 'Table'[Random] ) )
VAR _color =
    IF ( __RAND, "red", "green" ) --replace with the desired color, you can use hex or RGB
VAR LeftPad = 0
VAR UpperPad = 5
VAR _Pad = LeftPad & ", " & UpperPad
VAR _circle = "<circle cx='50' cy='50' r='40' fill='" & _color & "' transform='translate(" & _Pad & ")' />"
VAR _vbSize = " 110 110 " -- reduce to increase circle size
VAR svg = "data&colon;image/svg+xml;utf8," & "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 " & _vbSize & "'>" & _circle & "</svg>"
RETURN
    svg

danextian_1-1727261341731.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

7 REPLIES 7
Uzi2019
Super User
Super User

Hi @DongdongYu 

 

You can try below video for better understanding

https://www.youtube.com/watch?v=MGcYfCpwDds

https://www.youtube.com/watch?v=lfqPpUdtTss

 

 

https://www.youtube.com/watch?v=gCbBarkiH3c

https://www.youtube.com/watch?v=o2jSUHU722w

 

I hope combination of above videos will help you to resloved your issue!.

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
danextian
Super User
Super User

You should be able to use conditional formatting with icons.

danextian_0-1727238579261.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thanks, but 'condition formatting' cannot change the dot size.

You can use create a measure that generates a SVG image of a circle. ease see sample pbix

Circle = 
VAR __RAND =
    ISODD ( SELECTEDVALUE ( 'Table'[Random] ) )
VAR _color =
    IF ( __RAND, "red", "green" ) --replace with the desired color, you can use hex or RGB
VAR LeftPad = 0
VAR UpperPad = 5
VAR _Pad = LeftPad & ", " & UpperPad
VAR _circle = "<circle cx='50' cy='50' r='40' fill='" & _color & "' transform='translate(" & _Pad & ")' />"
VAR _vbSize = " 110 110 " -- reduce to increase circle size
VAR svg = "data&colon;image/svg+xml;utf8," & "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 " & _vbSize & "'>" & _circle & "</svg>"
RETURN
    svg

danextian_1-1727261341731.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
vicky_
Super User
Super User

You can use a method similar to the one described here: https://www.sqlbi.com/articles/creating-custom-visuals-in-power-bi-with-dax/

 

Basically, you will need to create a measure that returns a different colour / size of circle based on the values in your data - check the section called "Making the SVG dynamic with DAX" 

Thanks, I'll try it.

DongdongYu
New Member

I know I can use 'table' and apply 'condition formatting' to present the status, but unfortunately, in this way, I can't change the size and shape of the points.  So I was wondering how can I use 'shape' to achieve my target. 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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