Skip to content

SVG

Wraps content in SVG container for Power BI visualization

Tip

Any measures use these UDFs must have DataCategory = "ImageUrl"

DaxLib.SVG.SVG( width, height, viewbox, contents, sortValue )
Parameter Type Required Description
width STRING width (pixels or percentage)
height STRING height (pixels or percentage)
viewbox STRING Optional: viewBox (e.g., "0 0 100 100")
contents STRING To include one or more SVG elements (e.g., from DaxLib.SVG.Element functions)
sortValue NUMERIC Optional: Sort value for ordering in tables

STRING SVG string

DaxLib.SVG.SVG(
    "100",
    "100",
    "viewBox='0 0 100 100' ",
    DaxLib.SVG.Element.Circle("50", "50", "40", "fill='blue'", BLANK()),
    1
)
function 'DaxLib.SVG.SVG' =
        (
            width : STRING,
            height : STRING, 
            viewbox : STRING,
            contents : STRING,
            sortValue : NUMERIC
        ) =>

            "data:image/svg+xml;utf8," &
            "<svg " & 
            "width='" & width & "' height='" & height & "' " &
            IF( NOT ISBLANK( viewbox ), "viewBox='" & viewbox & "' " ) &
            "xmlns='http://www.w3.org/2000/svg'>" &
            IF( NOT ISBLANK( sortValue ), "<desc>" & FORMAT( sortValue, "000000000000" ) & "</desc>" ) &
            contents &
            "</svg>"