dax

How to write a conditional measure using SVG code?


I am trying to personalize a measure with an svg icon. But the code below seems not working even though I am saving the measure as image url. how to get around with this ? many thanks in advance.

FunnelColorIcon = 
    IF(
        ISFILTERED(tbl[col]),
        "data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' fill='red'%3E%3Cpath d='M6 8h36l-14 16v12l-8-6v-6L6 8z' /%3E%3C/svg%3E",
        "data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' fill='green'%3E%3Cpath d='M6 8h36l-14 16v12l-8-6v-6L6 8z' /%3E%3C/svg%3E"
    )

Solution

  • Seems your SVG string has been encoded, it should simply be:

    FunnelColorIcon = 
      IF(
        ISFILTERED(tbl[col]),
          "data:image/svg+xml;utf8, <svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' fill='red'><path d='M6 8h36l-14 16v12l-8-6v-6L6 8z' /></svg>",
          "data:image/svg+xml;utf8, <svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' fill='green'><path d='M6 8h36l-14 16v12l-8-6v-6L6 8z' /></svg>"
        )