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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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

 

 










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


Proud to be a Super User!









"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

 










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


Proud to be a Super User!









"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

 

 










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


Proud to be a Super User!









"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
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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.