Forum Discussion
Anonymous
9 years agoNot 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'...
Anonymous
4 years agoNot applicable
Again Thank KNP
Do You have any alternate solution?
Rudz
4 years agoKudo Collector
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.