Search code examples
powerbidax

Set Conditional Color formatting Slicer on Measure Value


I have two Slicers with Years. Trying to set Background of one of them depending on Value in another. Set Background-> Conditional Formatting -> Field Value -> WrongYearSelected

where:

WrongYearSelected = IF((SELECTEDVALUE('dim_date'[Year]) <= 'ComparisonYear'[YearSelected]), "Yellow")

What I'm doing wrong?

tried to use Measure, Calculated Field for thatr


Solution

  • For best results, I recommend putting a shape behind your slicer and setting the shape color to your measure. Then make the background of your slicer transparent. This measure I got working by using a shape:

    WrongYearSelected = 
    VAR dimDate = MIN('dim_date'[Year])
    VAR compYear = MIN('ComparisonYear'[YearSelected])
    
    RETURN
    IF( dimDate <= compYear, "Yellow","White")
    

    As a side note, I recommend this method because (in my research) changing the background of the slicer was hit or miss. That measure would only work when applied to the ComparisonYear slicer and the dimDate slicer was changed.