Forum Discussion

oakgogo's avatar
oakgogo
Icon for Helper II rankHelper II
2 years ago
Solved

can SVG expert solve this?

I want to create a SVG image to show in the new card visual, I am not skilled at SVG and now I can only create some text, and I want to do is add 3 element in card visual. first one is text informat...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi oakgogo ,

    Please try below dax formula:

    SVG =
    VAR textColor =
        IF ( [cal] > 0, "green", "red" )
    VAR arrow =
        IF ( [cal] > 0, "↑", "↓" )
    VAR SVG =
        "data:image/svg+xml;utf8,
    <svg xmlns='http://www.w3.org/2000/svg' height='40' width='150'>
        <g>
            <text fill='" & textColor & "' font-size='12'>
                <tspan x='6' y='20'>Ach:</tspan>
                <tspan x='6' y='38'>GR:</tspan>
                <tspan x='36' y='20'>"
            & FORMAT ( [cal], "0%" ) & "</tspan>
                <tspan x='36' y='38'>"
            & FORMAT ( [cal_2], "0%" ) & "</tspan>
            </text>
            <text fill='" & textColor & "' font-size='12' x='100' y='20'>" & arrow & "</text>
        </g>
    </svg>"
    RETURN
        SVG
    

     

    Best regards,
    Community Support Team_Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.