skip to main content
Power BI
    • What is Power BI
    • Why Power BI
    • Customer stories
    • Data visuals
    • Security
    • Power BI Desktop
    • Power BI Pro
    • Power BI Premium
    • Power BI Mobile
    • Power BI Embedded
    • Power BI Report Server
  • Pricing
    • Azure + Power BI
    • Microsoft 365 + Power BI
    • Dynamics 365 + Power BI
      • Energy
      • Healthcare
      • Manufacturing
      • Media
      • Retail
    • For analysts
    • For IT
      • Overview
      • Embedded analytics
      • Power BI visuals
      • Automation
      • Documentation
      • Community
    • Getting started
      • Overview
      • Self-guided learning
      • Webinars
      • Documentation
      • Roadmap
      • Overview
      • Issues
      • Give feedback
    • Blog
    • Business intelligence topics
    • Overview
    • Forums
    • Galleries
    • Submit ideas
    • Events
    • User groups
    • Community blog
    • Register
    • ·
    • Sign in
    • ·
    • Help
    Go To
    • Microsoft Power BI Community
    • Welcome to the Community!
    • News & Announcements
    • Get Help with Power BI
    • Desktop
    • Service
    • Report Server
    • Power Query
    • Mobile Apps
    • Developer
    • DAX Commands and Tips
    • Custom Visuals Development Discussion
    • Health and Life Sciences
    • Power BI Spanish Community
    • Translated Spanish Desktop
    • Power Platform Integration - Better Together!
    • Power Platform Integrations
    • Power Platform and Dynamics 365 Integrations
    • Training and Consulting
    • Instructor Led Training
    • Galleries
    • Community Connections & How-To Videos
    • COVID-19 Data Stories Gallery
    • Themes Gallery
    • Data Stories Gallery
    • R Script Showcase
    • Webinars and Video Gallery
    • Quick Measures Gallery
    • 2021 MSBizAppsSummit Gallery
    • 2020 MSBizAppsSummit Gallery
    • 2019 MSBizAppsSummit Gallery
    • Events
    • Ideas
    • Custom Visuals Ideas
    • Issues
    • Issues
    • Events
    • Upcoming Events
    • Community Engagement
    • T-Shirt Design Challenge 2023
    • Community Blog
    • Power BI Community Blog
    • Custom Visuals Community Blog
    • Community Support
    • Community Accounts & Registration
    • Using the Community
    • Community Feedback
    cancel
    Turn on suggestions
    Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
    Showing results for 
    Search instead for 
    Did you mean: 
    • Microsoft Power BI Community
    • Galleries
    • Quick Measures Gallery
    • SVG Multi-Shape, Multi-Color Indicators

    SVG Multi-Shape, Multi-Color Indicators

    08-27-2018 12:31 PM - last edited 08-28-2018 11:55 AM

    Super User Greg_Deckler
    Super User
    9891 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    Greg_Deckler
    Super User Greg_Deckler
    Super User
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    SVG Multi-Shape, Multi-Color Indicators

    ‎08-27-2018 12:31 PM

    One of the community blog posts that I have referrred to multiple times since it was published was @Dianapo's Power BI Desktop: Custom Aggregations, Formatting and Performance Indicators:

     

    https://community.powerbi.com/t5/Community-Blog/Power-BI-Desktop-Custom-Aggregations-Formatting-and-...

     

    However, since discovering this technique I have run into some limitations with using UNICODE characters for indicators, namely the available shape and color options are fairly limited. However, the ability to tag measures as Image URL's and support for SVG functionality have provided a solution to these limitations that I present here. And since SVG Quick Measures are all the rage these days, I figured I'd create one of my own.

     

    The two measures presented here provide a measure that produces different colors of all the same shapes based on some indicator criteria and another that modifies both color and shape based upon an indicator criteria. Enjoy!

     

    Color changes with the same shape (based on a slicer selection):

     

    Measure = 
    VAR __shape =
        IF(HASONEVALUE(Shapes[Shape]),MAX(Shapes[Shape]),"Circle")
    VAR __indicator = SUM([Column1])
    VAR __radius = 9
    VAR __opacity = 0.75
    VAR __color =
        SWITCH(
            TRUE(),
            __indicator<=-5,"DarkOrchid",
            __indicator<=-4,"DarkBlue",
            __indicator<=-3,"Blue",
            __indicator<=-2,"FireBrick",
            __indicator<=-1,"Red",
            __indicator=0,"Gold",
            __indicator>=5,"HotPink",
            __indicator>=4,"Orange",
            __indicator>=3,"Tomato",
            __indicator>=2,"SpringGreen",
            __indicator>=1,"Green",
            "White"
        )
    VAR __header = "data&colon;image/svg+xml;utf8," &
                  "<svg xmlns='http://www.w3.org/2000/svg' x='0px' y='0px' width='50' height='20'>"
    VAR __footer = "</svg>"
    VAR __shapeTextCircle = "<circle cx='10' cy='10' r='" & __radius & "' fill='" & __color & "' fill-opacity='" & __opacity & "' />"
    VAR __shapeTextTriangle = "<polygon points=""0,20 20,20 10,0"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeTextDot = "<circle cx='10' cy='10' r='" & 1 & "' fill='" & __color & "' fill-opacity='" & __opacity & "' />"
    VAR __shapeTextSquare = "<polygon points=""0,20 0,0, 20,1 20,20"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeTextDiamond = "<polygon points=""10,0 20,10, 10,20 0,10"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeTextRect = "<polygon points=""0,20 0,0, 40,1 40,20"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeTextHex = "<polygon points=""10,0 20,4 20,16 10,20 0,16 0,4"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeTextOct = "<polygon points=""6,0 14,0 20,6 20,14 14,20 6,20 0,14 0,6"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeTextPent = "<polygon points=""10,0 20,8 16,20 4,20 0,8"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeTextStar = "<polygon points=""10,0 12,9 20,8 13,13 16,20 10,15 4,20 7,13 0,9 8,9"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeText =
        SWITCH(__shape,
            "Triangle",__shapeTextTriangle,
            "Circle",__shapeTextCircle,
            "Dot",__shapeTextDot,
            "Square",__shapeTextSquare,
            "Rectangle",__shapeTextRect,
            "Hexagon",__shapeTextHex,
            "Octagon",__shapeTextOct,
            "Pentagon",__shapeTextPent,
            "Star",__shapeTextStar,
            "Diamond",__shapeTextDiamond,
            __shapeTextCircle
        )
    VAR __return = __header & __shapeText & __footer
    RETURN __return

     

    Color and shape changes:

     

    Measure 2 = 
    VAR __shape =
        IF(HASONEVALUE(Shapes[Shape]),MAX(Shapes[Shape]),"Circle")
    VAR __indicator = SUM([Column1])
    VAR __radius = 9
    VAR __opacity = 0.75
    VAR __color =
        SWITCH(
            TRUE(),
            __indicator<=-5,"DarkOrchid",
            __indicator<=-4,"DarkBlue",
            __indicator<=-3,"Blue",
            __indicator<=-2,"FireBrick",
            __indicator<=-1,"Red",
            __indicator=0,"Gold",
            __indicator>=5,"HotPink",
            __indicator>=4,"Orange",
            __indicator>=3,"Tomato",
            __indicator>=2,"SpringGreen",
            __indicator>=1,"Green",
            "White"
        )
    VAR __header = "data&colon;image/svg+xml;utf8," &
                  "<svg xmlns='http://www.w3.org/2000/svg' x='0px' y='0px' width='50' height='20'>"
    VAR __footer = "</svg>"
    VAR __shapeTextCircle = "<circle cx='10' cy='10' r='" & __radius & "' fill='" & __color & "' fill-opacity='" & __opacity & "' />"
    VAR __shapeTextDiamond = "<polygon points=""10,0 20,10, 10,20 0,10"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeTextTriangle = "<polygon points=""0,20 20,20 10,0"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeTextDot = "<circle cx='10' cy='10' r='" & 1 & "' fill='" & __color & "' fill-opacity='" & __opacity & "' />"
    VAR __shapeTextSquare = "<polygon points=""0,20 0,0, 20,1 20,20"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeTextRect = "<polygon points=""0,20 0,0, 40,1 40,20"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeTextHex = "<polygon points=""10,0 20,4 20,16 10,20 0,16 0,4"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeTextOct = "<polygon points=""6,0 14,0 20,6 20,14 14,20 6,20 0,14 0,6"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeTextPent = "<polygon points=""10,0 20,8 16,20 4,20 0,8"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeTextStar = "<polygon points=""10,0 12,9 20,8 13,13 16,20 10,15 4,20 7,13 0,9 8,9"" style=""fill:" & __color & ";stroke:" & __color & ";stroke-width:0;fill-rule:evenodd;"" />"
    VAR __shapeText =
        SWITCH(
            TRUE(),
            __indicator<=-5,__shapeTextCircle,
            __indicator<=-4,__shapeTextDot,
            __indicator<=-3,__shapeTextHex,
            __indicator<=-2,__shapeTextOct,
            __indicator<=-1,__shapeTextPent,
            __indicator=0,__shapeTextRect,
            __indicator>=5,__shapeTextSquare,
            __indicator>=4,__shapeTextTriangle,
            __indicator>=3,__shapeTextStar,
            __indicator>=2,__shapeTextDiamond,
            __indicator>=1,__shapeTextCircle,
            __shapeTextCircle
        )
    VAR __return = __header & __shapeText & __footer
    RETURN __return

     

     NOTE: In the __header VAR, you need to change the &colon; to an actual colon ( : )

     

     

     

     

     

    eyJrIjoiMzI4Mjc5MWUtNjA5OS00ZmRmLTkzZGItZWI4MzFjMGQwMjgyIiwidCI6IjRhMDQyNzQzLTM3M2EtNDNkMi04MjdiLTAwM2Y0YzdiYTFlNSIsImMiOjN9


    @ me in replies or I'll lose your thread!!!
    Instead of a Kudo, please vote for this idea
    Become an expert!: Enterprise DNA
    External Tools: MSHGQM
    YouTube Channel!: Microsoft Hates Greg
    Latest book!:
    Mastering Power BI 2nd Edition

    DAX is easy, CALCULATE makes DAX hard...
    Preview file
    11 KB
    SVGIndicators.pbix
    Labels:
    • Labels:
    • Other
    Message 1 of 3
    9,891 Views
    1
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic
    Dianapo
    Microsoft Dianapo
    Microsoft
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎08-27-2018 04:51 PM

    Thanks Greg for mentioning my article and also for all the helpful info in yours.  Below also including the link to the color indicator article as the one you have is for the custom aggregations. I totally made it confusing as I published two different articles with the same name and adding part 1 and part 2 in the end 🙂

     

    https://community.powerbi.com/t5/Community-Blog/Power-BI-Desktop-Custom-Aggregations-Formatting-and-...

     

    Cheers,

    Diana

    Message 2 of 3
    9,859 Views
    2
    Reply
    Greg_Deckler
    Super User Greg_Deckler
    Super User
    In response to Dianapo
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎08-28-2018 06:24 AM

    Appreciate your input @Dianapo! I really have gotten a ton of mileage out of your article. I've used that technique on a number of projects. Really appreciate your contributions to the community!


    @ me in replies or I'll lose your thread!!!
    Instead of a Kudo, please vote for this idea
    Become an expert!: Enterprise DNA
    External Tools: MSHGQM
    YouTube Channel!: Microsoft Hates Greg
    Latest book!:
    Mastering Power BI 2nd Edition

    DAX is easy, CALCULATE makes DAX hard...
    Message 3 of 3
    9,838 Views
    0
    Reply

    Power Platform

    • Overview
    • Power BI
    • Power Apps
    • Power Pages
    • Power Automate
    • Power Virtual Agents

    • Sign in
    • Sign up

    Browse

    • Solutions
    • Consulting Services

    Downloads

    • Power BI Desktop
    • Power BI Mobile
    • Power BI Report Server
    • See all downloads

    Learn

    • Guided learning
    • Documentation
    • Support
    • Community
    • Give feedback
    • Webinars
    • Developers
    • Blog
    • Newsletter

    © 2023 Microsoft

    Follow Power BI

    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Trademarks
    Consumer Privacy Act (CCPA) Opt-Out Icon Your Privacy Choices