Forum Discussion
Dynamical conditional formatting for multiple columns
- 8 months ago
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
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