Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Conditional Formatting of Alternating Column Colors Breaks When Filtering

Hello! I need to alernate the column colors on a matrix.  I was able to figure this out through a tutorial (ADVANCED Matrix Formatting I ALTERNATE Column or Row COLOR in Power BI - YouTube).  Howe...
  • MFelix's avatar
    MFelix
    3 years ago

    Hi Anonymous ,

     

    This is related with the RANKX part of your calculation in RANK you need to use the RANKX on a measure there is the need to force the iteration between rows and that is made using the CALCULATE in this case you need to redo your measure to:

     

    Formatting - AlternateColumns = 
    VAR SelectedCode = SELECTEDVALUE('Table'[Code])
    VAR RankTable = ALLSELECTED('Table'[Code])
    
    VAR CodeRank =
    RANKX
    (
        RankTable,
        CALCULATE(MAX('Table'[Code])),
        SelectedCode,
        ASC,
        Dense
    )
    
    VAR ConditionalFormatting = IF(ISEVEN(CodeRank), "Lightblue", "Lightgreen")
    RETURN ConditionalFormatting

     

    As you can see I have changed the Table[Code] by a CALCULATE(MAX(Table[Code])) this will force the line by line iteraction that the RANKX needs (blog post with explanation😞