Search code examples
powerbidaxconditional-formattingpowerbi-desktop

Reformatting column in Power BI


I am migrating a dashboard from Tableau to Power BI. I have a (Y/N) column for personal information as shown in the picture below:

Here

Is it possible to format that column, so it looks something similar to this in Power BI?:

Here

Update Screenshot: enter image description here


Solution

  • Yeah, pretty easy

    Measure = 
    VAR _1 =
    MAX ( 'fact'[personalInfo] )
    VAR _2 =
    SWITCH ( TRUE (), _1 = BLANK (), "🟦", _1 = "Y", "🟧", "🟥" )
    RETURN
    _2
    

    Solution

    More granular level

    Measure2 = 
    VAR _1 =
        MAX ( 'fact'[personalInfo] )
    VAR _blue = "data:image/svg+xml;utf8,
                    <svg xmlns=""http://www.w3.org/2000/svg"" width='100 px' height='100px' viewBox='0 0 100 100'>                  
                             <rect width=""30"" height=""30"" x=""35"" y=""35"" style=""fill:#4E79A7"" />
                </svg>" 
    VAR _orange = "data:image/svg+xml;utf8,
                    <svg xmlns=""http://www.w3.org/2000/svg"" width='100 px' height='100px' viewBox='0 0 100 100'>                  
                             <rect width=""30"" height=""30"" x=""35"" y=""35"" style=""fill:#F28E2B"" />
                </svg>" 
    VAR _red = "data:image/svg+xml;utf8,
                    <svg xmlns=""http://www.w3.org/2000/svg"" width='100 px' height='100px' viewBox='0 0 100 100'>                  
                             <rect width=""30"" height=""30"" x=""35"" y=""35"" style=""fill:#E15759"" />
                </svg>" 
    VAR _2 =
        SWITCH ( TRUE (), _1 = BLANK (), _blue ,_1 = "Y", _orange, _red)
    RETURN
        _2
    

    Solution