This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
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-num...
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.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 30 | |
| 24 | |
| 23 | |
| 17 | |
| 16 |
| User | Count |
|---|---|
| 61 | |
| 35 | |
| 30 | |
| 23 | |
| 23 |