Forum Discussion

ThimmaiahS's avatar
ThimmaiahS
New Member
8 months ago
Solved

Dynamical conditional formatting for multiple columns

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...
  • Praful_Potphode's avatar
    Praful_Potphode
    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