Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
Hello Community,
I have
Is there any possible way to apply conditional formatting for multiple columns with dynamic dax.
suppose if columns contains values like:
A1, then fill the Green colour as background,
B1,then full the blue colour as background,
.......... I1, then fill the yellow colour as background.
Regards,
ThimmaiahS
Solved! Go to Solution.
Hi @ThimmaiahS ,
if you have 365 columns for 365 days then its advisable to unpivot the data in Power Query and then use it for filtering and conditional formatting.
if you still want to keep all columns intact then you can write switch statement for managing the conditional formatting.something like below.
Dynamic Background Color =
VAR CurrentValue = SELECTEDVALUE( 'YourTable'[YourValueColumn] )
-- Note: If your values are aggregations (like count/sum), use that measure instead
-- e.g., VAR CurrentValue = [Total Count]
RETURN
SWITCH( TRUE(),
CurrentValue = "A1", "#00FF00", -- Green
CurrentValue = "B1", "#0000FF", -- Blue
CurrentValue = "I1", "#FFFF00", -- Yellow
"#FFFFFF" -- Default White
)
Please give kudos or mark it as solution once confirmed.
Thanks and Regards,
Praful
Hi @ThimmaiahS ,
Please try links suggested by @123abc .
if it doesnt work, please help us with sample data/input/output screenshot.
Thanks and regards,
Praful
Following community solution can help you:
Conditional Formatting Using Custom Measure - Microsoft Fabric Community
Solved: Color coding with DAX - Microsoft Fabric Community
Power BI Conditional Formatting Based On Field Value
Using field parameters and calculation groups for conditional formatting - SQLBI
sure sir you can apply dynamic conditional formatting across multiple columns in a Power BI table/matrix using “Format by: Field value” with a DAX measure (or with Field Parameters if you want the column to switch dynamically).
you can try give below step and apply them:
If your table has columns like A,B,C and each cell contains values like A1, B1 … I1, you can create one measure per column returning a color and then set conditional formatting to “Format by > Field value > pick that measure”.
Hello Sir,
Thanks for the solution,
we have many columns example we are taking calendar days 365 days and cannot have 365 measures, so we need one measure which can work for all the columns.
Regards
Hi @ThimmaiahS ,
if you have 365 columns for 365 days then its advisable to unpivot the data in Power Query and then use it for filtering and conditional formatting.
if you still want to keep all columns intact then you can write switch statement for managing the conditional formatting.something like below.
Dynamic Background Color =
VAR CurrentValue = SELECTEDVALUE( 'YourTable'[YourValueColumn] )
-- Note: If your values are aggregations (like count/sum), use that measure instead
-- e.g., VAR CurrentValue = [Total Count]
RETURN
SWITCH( TRUE(),
CurrentValue = "A1", "#00FF00", -- Green
CurrentValue = "B1", "#0000FF", -- Blue
CurrentValue = "I1", "#FFFF00", -- Yellow
"#FFFFFF" -- Default White
)
Please give kudos or mark it as solution once confirmed.
Thanks and Regards,
Praful
Hi @ThimmaiahS ,
Thanks for the follow up.
As @123abc already pointed out, Power BI applies background-color formatting at the field level, so a single DAX measure cannot automatically drive color across many separate physical columns. The “Format by -> Field value” option always expects one measure or one field per formatted column, which is why your model structure becomes key.
If your 365 day fields exist as separate columns in the table, Power BI does not support a method for one DAX expression to detect which column is being formatted and return column-specific colors.
For more details, pease visit: Apply Conditional Table Formatting in Power BI - Power BI | Microsoft Learn
Most solutions involve reshaping the data so that day values are unpivoted into rows rather than maintained as separate columns. Once the data is in a normalized form (one date-or-day field, one value field), you can apply a single color measure across the visual.
A similar recommendation and discussion is found here: Solved: How to apply the same conditional formatting on mu... - Microsoft Fabric Community
If keeping all columns is unavoidable, the remaining options are per-column “rules” formatting or individual color measures per column. There is currently no built-in “apply same conditional format to multiple columns” feature in Power BI.
Also an idea related to this already exists: Conditional Formatting - Microsoft Fabric Community
Please upvote the idea if this matches your requirement.
If you are able to share a small example of your table structure showing how day values are stored, the community could help suggest whether reshaping (unpivoting) might allow you to use a single measure instead of many.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community
Hope this helps. Please reach out for further assistance.
Thank you.
Hi @ThimmaiahS ,
Just wanted to check whether the response provided was helpful. Also, have you had a chance to review the idea included above. If it aligns with your requirement, kindly upvote it so that it gains more visibility and may be considered for future implementation.
If you need any further assistance, please reach out and consider sharing sample data so that we can support you better.
Thank you.
| User | Count |
|---|---|
| 6 | |
| 5 | |
| 5 | |
| 4 | |
| 3 |
| User | Count |
|---|---|
| 16 | |
| 11 | |
| 9 | |
| 8 | |
| 7 |