Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
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.
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 22 | |
| 22 | |
| 18 | |
| 16 | |
| 13 |
| User | Count |
|---|---|
| 63 | |
| 41 | |
| 40 | |
| 39 | |
| 38 |