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 Trend Indicator
    Accepted Solution

    SVG Trend Indicator

    08-13-2018 12:07 PM

    dgwilson
    Resolver III
    19973 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    dgwilson
    dgwilson Resolver III
    Resolver III
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    SVG Trend Indicator

    ‎08-13-2018 12:07 PM

    Just like SVG SparkLines this DAX produces a Trend indicator, Up/Down/Neutral.

    Add it as a field in your table, keyed off a numeric value to give you the up/down/neutral.

    One additional trick is to set the image size as small as possible (24) under Grid as part of the formatting.

     

    SVG Trend Indicator.PNG

    Trend_Image =

        VAR MessageText = ""

        VAR Radius = 9

        VAR Colour = "blue"

        VAR Opacity = 0.75

        VAR SVG_Neutral = "data:image/svg+xml;utf8," &

                  "<svg xmlns='http://www.w3.org/2000/svg' x='0px' y='0px' width='50' height='20'>" &

                  "<circle cx='25' cy='10' r='" & Radius & "' fill='" & Colour & "' fill-opacity='" & Opacity & "' />" &

                  "</svg>"

        VAR SVG_UP = "data&colon;image/svg+xml;utf8," &

                  "<svg xmlns='http://www.w3.org/2000/svg' x='0px' y='0px' width='50' height='20'>" &

                  "<polygon points=""05,20 45,20 25,1"" style=""fill:green;stroke:green;stroke-width:0;fill-rule:evenodd;"" />" &

                  "</svg>"

        VAR SVG_DN = "data&colon;image/svg+xml;utf8," &

                  "<svg xmlns='http://www.w3.org/2000/svg' x='0px' y='0px' width='50' height='20'>" &

                  "<polygon points=""05,1 45,1 25,20"" style=""fill:red;stroke:red;stroke-width:0;fill-rule:evenodd;"" />" &

                  "</svg>"

    RETURN

        IF('Customer KPI'[KPI_Trend] > 0, SVG_UP, IF('Customer KPI'[KPI_Trend] < 0, SVG_DN, SVG_Neutral))

     

    Preview file
    2 KB
    Labels:
    • Labels:
    • Other
    Message 1 of 18
    19,973 Views
    4
    Reply
    1 ACCEPTED SOLUTION
    dgwilson
    dgwilson Resolver III
    Resolver III
    In response to tomknight
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎08-15-2018 01:08 PM

    Thank you.

     

    Yes an issue with copy & paste. and Having tried it again, the editor here is doing "fancy" stuff that I cannot work around.

    The "magic" is attached in an image below.

     

     

    ThatTextForSVG.PNG

    Message 3 of 18
    20,279 Views
    0
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic
    tomknight
    tomknight Helper I
    Helper I
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-13-2019 12:53 AM

    This doesn't seem to work in the latest update of PowerBI service - I get a missing image placeholder instead of the SVG. Any idea why that might be? It still works fine in PBI Desktop but not in the service.

     

    Thanks,


    Tom

    Message 6 of 18
    17,896 Views
    0
    Reply
    dgwilson
    dgwilson Resolver III
    Resolver III
    In response to tomknight
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-13-2019 09:57 AM

    Likely a browser issue. Or browser version issue.

    Does it work in Chrome?

     

    - David

    Message 7 of 18
    17,864 Views
    0
    Reply
    tomknight
    tomknight Helper I
    Helper I
    In response to dgwilson
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-13-2019 10:16 AM
    Strangely it doesn’t work in Chrome or Firefox but it does work in Edge - never seen in issue like this that way round, its usually vice versa. I’ve raised a ticket with Microsoft so will see what they say.

    Thanks,

    Tom
    Message 8 of 18
    17,861 Views
    1
    Reply
    Anonymous
    Not applicable
    In response to tomknight
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-21-2019 07:01 PM

    Getting the same issue

    Message 11 of 18
    7,811 Views
    0
    Reply
    tomknight
    tomknight Helper I
    Helper I
    In response to Anonymous
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-22-2019 05:15 AM

    Microsoft have acknowledged it is a bug and i'm awaiting details of a fix. For now I had to bake the SVGs I wanted into files and host them then use a web URL as usual.

     

    I did notice that the images are still honoured if you export to PDF and it works in Edge just not other browsers.

    Message 12 of 18
    7,801 Views
    0
    Reply
    Anonymous
    Not applicable
    In response to tomknight
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-27-2019 09:43 PM

    Very interesting....I have the same issue.  For me, it is broken in Chrome, Edge, and Firefox however it works in Opera!  

     

    Any news from Microsoft?  I opened a support ticket a week ago and have heard nothing back from them.

    Message 13 of 18
    7,780 Views
    0
    Reply
    tomknight
    tomknight Helper I
    Helper I
    In response to Anonymous
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-28-2019 12:45 AM

    My ticket is still open and they are still discussing a solution as far as I know. I last heard from them a couple of days ago.

    Message 14 of 18
    7,774 Views
    0
    Reply
    tomknight
    tomknight Helper I
    Helper I
    In response to tomknight
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎03-08-2019 05:01 AM

    Microsoft have fixed this and should be released first week of April.

    Message 15 of 18
    7,668 Views
    0
    Reply
    Anonymous
    Not applicable
    In response to tomknight
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎04-10-2019 11:28 PM

    OK, SVG's are now rendering in tables, but not any of the image custom visuals... Which is not ideal as I cannot switch the column headings off for tables...

    Message 18 of 18
    7,499 Views
    0
    Reply
    Anonymous
    Not applicable
    In response to tomknight
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎04-10-2019 04:33 PM

    Any update?  Doesn't appear to be fixed yet?

    Message 17 of 18
    7,512 Views
    0
    Reply
    Anonymous
    Not applicable
    In response to tomknight
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎03-27-2019 06:37 PM

    OK - good to hear.  Thanks

    Message 16 of 18
    7,574 Views
    0
    Reply
    dgwilson
    dgwilson Resolver III
    Resolver III
    In response to tomknight
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-13-2019 10:47 AM

    That's really weird. "Everything" works in Chrome.

    The SVG code that you have (or are generating)... you can place in a txt file xyz.svg and open that in the browser... so you can test outside of Power BI. There maybe something in the SVG code or headers that is breaking the browser compatability?

     

    - David

    Message 9 of 18
    17,857 Views
    0
    Reply
    tomknight
    tomknight Helper I
    Helper I
    In response to dgwilson
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-13-2019 11:16 AM

    Just tried that and the SVG is sound. I have deployed this with different SVGs in 3 different projects and they all simultanously broke with the Feb update of PBI so there must be a change in PBI somewhere. I thought it might be due to "external" images so I took the URL of an SVG that I found online and put it into a table and set it to Web Image but that worked fine.

     

    Will keep you posted with what Microsoft say. They've asked for the PBIX file.

     

    Thanks for the help,

     

    Tom

    Message 10 of 18
    17,854 Views
    1
    Reply
    tomknight
    tomknight Helper I
    Helper I
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎08-14-2018 02:32 AM

    Thanks a lot for posting this - it's fantastic!

     

    The DAX didn't work out of the box for me (I got the broken image icon) but I followed the link in your other DAX based sparkline post and saw that the prefix for the SVG data was slightly different. I think the forum is changing the code when you save it.

     

    If you replace the "&colon;" in the code with an actual colon it works perfectly.

     

    Thanks again,


    Tom

    Message 2 of 18
    19,835 Views
    0
    Reply
    dgwilson
    dgwilson Resolver III
    Resolver III
    In response to tomknight
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎08-15-2018 01:08 PM

    Thank you.

     

    Yes an issue with copy & paste. and Having tried it again, the editor here is doing "fancy" stuff that I cannot work around.

    The "magic" is attached in an image below.

     

     

    ThatTextForSVG.PNG

    Message 3 of 18
    20,280 Views
    0
    Reply
    tomknight
    tomknight Helper I
    Helper I
    In response to dgwilson
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎11-27-2018 08:22 AM

    Hi,

     

    Does this work for you in a total row?

     

    It doesn't seem to work for me and I don't know why. It should calculate exactly the same shouldn't it?

     

    Thanks,


    Tom

    Preview file
    57 KB
    Message 4 of 18
    18,943 Views
    0
    Reply
    dgwilson
    dgwilson Resolver III
    Resolver III
    In response to tomknight
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎11-27-2018 10:02 AM

    That's a good question. I haven't used it in a total row.

    Message 5 of 18
    18,938 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