Forum Discussion

wcarter's avatar
wcarter
Advocate II
8 months ago
Solved

Font Size

PBI isn't letting me set font sizes above 60 on the cards. I have to create a one-page dashboard with some large elements and I need to be able to set a larger font size. This should be a free-form i...
  • danextian's avatar
    8 months ago

    Hi wcarter 

    You're right that max font size limit in Power BI is 60. A workaround is to use a DAX generated SVG image returning the desired value. The first card in the image below uses SVG while the second one uses the 60px limit. This is fine for a few measures but quite tricky to setup. DAX below was generated with the help of AI

    SVG_Responsive_Text =
    VAR _label = "Total Sales:"
    VAR _value = FORMAT( [Total Transactions], "#,0" )
    
    -- Large viewBox for better scaling
    VAR _vbW = 2000
    VAR _vbH = 1000
    
    -- Padding inside viewBox
    VAR _padX = _vbW * 0.05
    VAR _padY = _vbH * 0.1
    
    -- Font size relative to viewBox height
    VAR _fontSize = _vbH * 0.35
    
    -- Text position
    VAR _x = _padX
    VAR _y = _vbH / 2   -- vertically centered
    
    RETURN
    "data:image/svg+xml;utf8," &
    "<svg xmlns='http://www.w3.org/2000/svg' "
    & "width='100%' height='100%' "
    & "viewBox='0 0 " & _vbW & " " & _vbH & "'>"
        & "<rect width='100%' height='100%' fill='white'/>"
        & "<text x='" & _x & "' y='" & _y & "' "
            & "font-family='Segoe UI' "
            & "font-size='" & _fontSize & "' "
            & "dominant-baseline='middle' "
            & "text-anchor='start'>"
            & _label & " "
            & "<tspan font-weight='700'>" & _value & "</tspan>"
        & "</text>"
    & "</svg>"