Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Objective: Change background color using a HEX color code based on cell value for columns PBar_01 to PBar_14.
My current solution involves creating 14 measures for each column then use conditional formatting which seems quite cumbersome. Is there a better approach maybe using a function?
1. Create a new measure for PB01 column
2. Set conditional formatting for background colour for PB01:
3. Repeat steps 1 to 2 thirteen times for PB02>PB14
I have also used conditional formatting for the Font colour so that means an additional 14 measures. Surely there must be a way of creating a function whereby you feed in the Text value and it returns a colour without having to define the Column?
Hi @Anonymous ,
There is no good solution right now, you need to create so many measures manually.
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , You can create a color measure than return color based on condition and use that with "Field" option in conditional formatting
color =
switch ( true(),
FIRSTNONBLANK(Table[commodity],"NA") ="commodity1" && sum(Table[Value]) >500,"lightgreen",
FIRSTNONBLANK(Table[commodity],"NA") ="commodity2" && sum(Table[Value]) >1000,"lightgreen",
/// Add more conditions
"red"
)
https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-numbers-in-the-column
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values
But how can this measure be applied to each column? What is Table[Commodity] and Table[Value]? I need to appy conditional formatting based on the value in the specific cell, for each column.
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 48 | |
| 40 | |
| 38 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 68 | |
| 65 | |
| 30 | |
| 26 | |
| 25 |