Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Color Individual rows in Power BI matrix

How do I change the color of a matrix row in Power BI Desktop (matrix visualization) ? Similar to Excel. I want let's say 2nd ,3rd  rows to have colors.

I tried to figure out for an hour but couldn't help it.

13 REPLIES 13
Anonymous
Not applicable

Is there any update on this question ? I want same output

 

I'm not sure replying to a post from 2017 is going to get you the best answer but I'll post this here in case it helps.

The basic pattern I follow is...

Create a measure with your rules that defines the colour you want. (adjust to suit your data)

Colour = 
VAR v =
    SELECTEDVALUE ( 'Table'[Column1] )
RETURN
    SWITCH (
        TRUE (),
        v = "a", "rgba(255,100,10,1)",
        v = "b", "rgba(10,10,255,1)",
        v = "g", "rgba(10,255,10,1)",
        v = "r", "rgba(255,10,10,1)"
    )

 

Right click on the value/measure in the fields of your matrix and select 'Conditional Formatting' >> 'Background Colour' (or whichever formatting option you want). 

Choose field value and your colour measure.

KNP_0-1638220759622.gif

Hope this helps.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x
Anonymous
Not applicable

Hi KNP 
 Thanks for your quick reponse
The requirement is I have to show color coding( Conditional Formatting) for the  Single row where I have dates ( in row  section ).Here the logic is the row (say project) which has the dates less than current date  I have to show RED color .
Power bi facilitates  Conditional Formatting only for the values section.
So I want color code for the sinle row in row section.
Thank You KNP

Makes sense, I don't think what you need is currently possible. Also mentioned here...

https://community.powerbi.com/t5/Desktop/Matrix-Grouping-Conditional-formatting/m-p/2212710/highligh...

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x
Anonymous
Not applicable

Again Thank KNP

Do You have any alternate solution?

 

Try using HTML. See Building a custom Gauge Table with HTML (kerrykolosko.com) for a nice walkthrough. 

 

I threw together a quick sample following it that worked fine.

HTML Table = 
    VAR SourceData =
        ADDCOLUMNS(
            SUMMARIZE(
                'Projects',
                'Projects'[Project],Projects[Date]
            ),
            "#", COUNTROWS('Projects')
        )
    VAR TableRow =
        CONCATENATEX(
            SourceData,
            "<tr class='"&[DateFlag]&"'>"
                /* column 1 */
                & "<td style='width: 40%;'>"
                & [Project]
                & "</td>"
                /* column 2 */
                & "<td><strong>"
                & [Date]
                & "</strong></td>"
                /* column 3 */
                & "<td style='width: 40%;'>"
                & [#]
                & "</td>"
            & "</tr>"
        )
    RETURN
        /* Table Styling */
        "<style>
            table {width: 100%;font-size: 12pt;} td {font-size: 12pt; padding: 3px; border-bottom: 1px solid #ddd;} 
            table tr[class='TRUE'] td {background:#FF0000;}
            table tr[class='FALSE'] td {background:none;}
        </style>"
        /* Table and heading row */
        & "<table>
            <thead>
                <tr>
                    <th>Project</th>
                    <th>Date</th>
                    <th>Count</th>
                </tr>
            </thead>
            <tbody>"
        /* Data */
        & TableRow
        /* End of table */
        & " </tbody>
        </table>"   

With the color being set by:

DateFlag = MAX(Projects[Date]) < TODAY()

If you want multiple colors, I would just set the color value in a measure and change the HTML to set the background color in TableRow instead of the style section.

 

If you need to export to PDF or PowerPoint, use the Shielded HTML custom visual.

The best alternative, which in most cases isn't an option, is to use the Table visual instead of the Matrix visual. This gives you more control over the formatting.

 

One other possibility, check the maketplace to see if there are any custom visuals that could work. Here's one possibility. I've never used it but the reviews look good.

https://appsource.microsoft.com/en-us/product/power-bi-visuals/WA200000642

KNP_0-1638381077910.png

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x
Anonymous
Not applicable

Is there any update on this question ? I want same output

 

Phil_Seamark
Employee
Employee

Hi @Anonymous

 

Have you played with this property of the Matrix?

 

Grid Rows.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

Hi @Phil_Seamark. This does color the matrix. But I am specifically looking to color only the rows of my interest. I still cannot do that with this option. 

Example:

There are 50 rows in the matrix and I just want to highlight 10th and 23rd rows. In this scenario this doesn't work.

Hi @Anonymous,

 

If the current Matrix Conditional Formatting option cannot meet your needs, I would suggest you vote this similar idea shared on Power BI ideas and add your comments there to improve Power BI on this feature.Smiley Happy

 

Regards

Anonymous
Not applicable

Thank You @v-ljerr-msft

Anonymous
Not applicable

Is there any update on this thread? Is this feature included now?

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.